HTTP Header

An HTTP header is metadata included in an HTTP request or response. It conveys information like content type, length, encoding, authentication tokens, and caching preferences.

Also known as: Header fields, HTTP metadata.

Comparisons

  • HTTP Header vs. HTTP Body: Headers provide metadata, while the body contains the actual content.
  • Custom vs. Standard Headers: Standard headers follow predefined formats, while custom headers are user-defined for specific needs.

Pros

  • Enhances communication: Specifies data handling preferences.
  • Enables authentication: Includes tokens or credentials for secure access.

Cons

  • Increased size: Can add overhead to requests and responses.
  • Security exposure: Sensitive data in headers can be exploited.

Example


GET /api/data HTTP/1.1
Host: example.com
Authorization: Bearer abc123token
Content-Type: application/json
User-Agent: MyApp/1.0
Accept: application/json

This HTTP request includes headers like Authorization for authentication, Content-Type to indicate JSON data, and User-Agent to identify the client application. These headers help servers process the request appropriately.

© 2018-2025 decodo.com. All Rights Reserved