Skip to content

Header

Easy — everyone uses thisNetworking

ELI5 — The Vibe Check

Headers are the metadata attached to HTTP requests and responses — information about the information. Like the label on a package: who sent it, what's inside, how big it is, what language it's in. The actual content (body) is separate from the headers.

Real Talk

HTTP headers are key-value pairs that convey metadata about a request or response. Request headers include things like Authorization, Content-Type, Accept, and User-Agent. Response headers include Content-Type, Cache-Control, Set-Cookie, and CORS headers. Headers are case-insensitive.

Show Me The Code

// Reading and setting headers in Express
app.get('/data', (req, res) => {
  // Read request headers
  const auth = req.headers['authorization'];
  const type = req.headers['content-type'];

  // Set response headers
  res.setHeader('X-Custom-Header', 'my-value');
  res.setHeader('Cache-Control', 'max-age=3600');
  res.json({ data: 'value' });
});

When You'll Hear This

"Set the Authorization header for the API request." / "Check the response headers for the rate limit info."

Made with passive-aggressive love by manoga.digital. Powered by Claude.