HTTP Request Header Reference Table

HTTP Request Header

Header Explanation Example
Accept Specifies the content types that the client can accept Accept: text/plain, text/html
Accept-Charset Character sets that the browser can accept. Accept-Charset: iso-8859-5
Accept-Encoding Specifies the content-encoding types that the client can support for responses from the web server. Accept-Encoding: compress, gzip
Accept-Language Languages that the browser can accept Accept-Language: en,zh
Accept-Ranges Indicates that the client can request a range of the web entity Accept-Ranges: bytes
Authorization Authorization credentials for HTTP authorization Authorization: Authentication Credentials
Cache-Control Specifies caching mechanisms that should be followed by the request and the response Cache-Control: no-cache
Connection Indicates whether a persistent connection is needed. (HTTP 1.1 defaults to persistent connections) Connection: close
Cookie When an HTTP request is sent, it sends all cookie values stored under that request domain to the web server. Cookie: $Version=1; Skin=new;
Content-Length The length of the request content Content-Length: 348
Content-Type The MIME information corresponding to the request entity Content-Type: application/x-www-form-urlencoded
Date The date and time the request was sent Date: Tue, 15 Nov 2010 08:12:31 GMT
Expect Specific server behavior requested Expect: 100-continue
From Email of the user sending the request From: [email protected]
Host Specifies the domain name and port number of the server being requested Host: www.jsons.cn
If-Match Valid only if the request content matches the entity If-Match: "specific value"
If-Modified-Since The request is successful only if the requested part has been modified after the specified time; returns a 304 code if it has not been modified If-Modified-Since: Sat, 29 Oct 2010 19:43:31 GMT
If-None-Match Returns a 304 code if the content has not changed; the parameter is the Etag previously sent by the server, which is compared to the Etag returned by the server to determine if it has changed If-None-Match: "specific value"
If-Range If the entity has not changed, the server sends the part that the client is missing, otherwise sends the entire entity. The parameter is also the Etag If-Range: "specific value"
If-Unmodified-Since The request is successful only if the entity has not been modified after the specified time If-Unmodified-Since: Sat, 29 Oct 2010 19:43:31 GMT
Max-Forwards Limits the time the information is passed through proxies and gateways Max-Forwards: 10
Pragma Used to include specific directives for implementation Pragma: no-cache
Proxy-Authorization Authorization credentials to connect to the proxy Proxy-Authorization: Authorization credentials to connect to the proxy
Range Requests only a part of the entity, specifying the range Range: bytes=500-999
Referer The address of the previous webpage, the current requested webpage follows it, i.e., the source. Referer: http://www.jsons.cn
TE The transfer encodings the client is willing to accept, and informs the server to handle trailer information TE: trailers,deflate;q=0.5
Upgrade Specifies a certain transfer protocol to the server so that the server can convert (if supported) Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11
User-Agent The content of User-Agent contains information about the user making the request User-Agent: Mozilla/5.0 (Linux; X11)
Via Notifies the address of the intermediate gateway or proxy server and the communication protocol. Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
Warning Warning information about the message entity Warn: 199 Miscellaneous warning

HTTP Responses Header

Header Explanation Example
Accept-Ranges Indicates whether the server supports specified range requests and what types of segment requests are supported Accept-Ranges: bytes
Age Estimated time (in seconds, non-negative) from the original server to the proxy cache Age: 12
Allow Effective request behaviors for a network resource; if not allowed, returns 405 Allow: GET, HEAD
Cache-Control Tells all caching mechanisms whether caching is allowed and which types Cache-Control: no-cache
Content-Encoding Content encoding types supported by the web server for the returned content. Content-Encoding: gzip
Content-Language Language of the response body Content-Language: en,zh
Content-Length The length of the response body Content-Length: 348
Content-Location An alternative address for the requested resource Content-Location: /index.htm
Content-MD5 MD5 checksum value of the returned resource Content-MD5: MD5 Checksum Value
Content-Range Byte position of this part in the entire returned body Content-Range: bytes 21010-47021/47022
Content-Type The MIME type of the returned content Content-Type: text/html; charset=utf-8
Date The time the original server message was sent Date: Tue, 15 Nov 2010 08:12:31 GMT
ETag The current value of the entity tag for the variable in the request ETag: "Current value of entity tag for variable"
Expires The expiration date and time of the response Expires: Thu, 01 Dec 2010 16:00:00 GMT
Last-Modified The last modified time of the requested resource Last-Modified: Tue, 15 Nov 2010 12:45:26 GMT
Location Used to redirect the recipient to a non-requested URL to complete the request or identify a new resource Location: http://www.jsons.cn
Pragma Includes directives that can apply to any recipient in the response chain Pragma: no-cache
Proxy-Authenticate Indicates the authentication scheme and parameters applicable to the URL on the proxy Proxy-Authenticate: Basic
refresh Used for redirection or when a new resource is created, redirecting after 5 seconds (proposed by Netscape, supported by most browsers)
Refresh: 5; url= http://www.jsons.cn
Retry-After If the entity is temporarily unavailable, notify the client to retry after the specified time Retry-After: 120
Server Name of the web server software Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
Set-Cookie Sets an HTTP cookie Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1
Trailer Indicates that header fields exist at the end of chunked transfer encoding Trailer: Max-Forwards
Transfer-Encoding File transfer encoding Transfer-Encoding:chunked
Vary Tells downstream proxies whether to use cached responses or request from the original server Vary: *
Via Informs the client of where the response was sent through the proxy Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
Warning Warning of potential issues with the entity Warning: 199 Miscellaneous warning
WWW-Authenticate Indicates the authorization scheme that the client's request entity should use WWW-Authenticate: Basic

HTTP Request Header Reference - Common Request and Response Headers Information Directory

This page provides a detailed reference table for HTTP Request Headers and HTTP Response Headers. HTTP request and response headers are important parts of web development, and developers need to understand these header information when writing crawlers, API interfaces, simulating logins, etc.

What are HTTP Request Headers and Response Headers?

HTTP Request Headers are metadata sent by the client to the server along with the request, informing the server of additional information about the request.
HTTP Response Headers are the metadata attached to the response sent back by the server, containing the status and processing information of the response.

Common HTTP Request Header Reference Table

The following are common HTTP request headers and their functions:

Request Header Purpose Description
User-Agent Information identifying the client browser or operating system, used to determine the client environment.
Accept Specifies the content types the client can process, telling the server the content type to return.
Host Specifies the target host and port of the request, commonly used for accessing virtual hosts.
Authorization Contains authentication information, used for API interface authorization.
Content-Type Informs the server of the type of request body, such as application/json, text/html, etc.
Accept-Encoding Specifies the content encoding methods supported by the client, such as gzip, deflate.
Cookie Contains the cookie data stored by the client, used for session management.
Referer Records the source URL of the request, usually used to analyze access sources.
Connection Specifies whether to keep the connection alive; common values are keep-alive or close.

Common HTTP Response Header Reference Table

The following are common HTTP response headers and their functions:

Response Header Purpose Description
Content-Type Specifies the data type of the response body, such as text/html, application/json, etc.
Content-Length Specifies the length of the response body, measured in bytes.
Set-Cookie Server sends cookie data to the client, used for session management.
Cache-Control Specifies caching strategies, such as no-cache, max-age, etc.
Location In redirect responses, specifies the URL of the new location.
Server Indicates the name and version information of the server.
Access-Control-Allow-Origin Specifies which domains are allowed to access the resource, commonly used for cross-origin requests.
Content-Encoding Specifies the encoding method of the response body, such as gzip, deflate.
Expires Specifies the expiration time for the response content, commonly used for cache control.

Application Scenarios of HTTP Request Headers and Response Headers

HTTP request headers and response headers have a wide range of applications in actual development. For example:

  • API Interfaces: Request headers for API interfaces are used to pass authentication information and request body types; response headers are used to return data formats, caching strategies, etc.
  • Simulated Login: When simulating a login, the Authorization request header commonly carries a token or cookie data to ensure user identity verification.
  • Crawlers: When writing web crawlers, the User-Agent in the request headers can simulate a browser to obtain content from the website.

Summary

Mastering the use of HTTP request headers and response headers is essential for developing efficient, standards-compliant web applications. With the HTTP Request Header Reference Table provided on this page, you can easily understand the functions and applications of common request and response headers, helping developers quickly get started with the HTTP protocol.

Your footpath:
Choose Language