HTTP protocol response header, request header detailed

Source: Internet
Author: User
Tags character set http cookie http request md5 time and date port number

1. HTTP request

The HTTP request consists of three parts, the request line, the message header, the request body

The HTTP request line begins with a method, begins with a space, followed by a URI and the HTTP protocol version, with a carriage return and a newline at the end of each line, CRLF identifies the carriage return line

Request Method:

Get: Request to get the resource identified by the URI

Post: Append new data to the resource identified by the URI

Head: Request for response header information for the resource identified by the URI

PUT: The server identified by the request URI stores a resource

Delete: Request server deletes the resource represented by the URI

TRACE: Request Server Loopback received request information for testing or diagnostics

CONNECT:

OPTIONS: Request the performance of the wipe server

Eg:get http://www.baidu.com/HTTP1.0 (CRLF)

Full Request instance: accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 (CRLF)
Accept-encoding:gzip, deflate, SDCH (CRLF)
accept-language:zh-cn,zh;q=0.8 (CRLF)
Connection:keep-alive (CRLF)
Cookie: (CRLF)
Host:www.baidu.com (CRLF)
Upgrade-insecure-requests:1 (CRLF)
user-agent:mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/45.0.2454.101 safari/537.36 (CRLF)
2. Request Header:

Allow clients to pass additional information to the server side

Accept: The Request header field is used to specify which types of information the client receives. such as: accept:image/gif,text/html

Specific point of type view http://tool.oschina.net/commons

Accept-charset: The Request header field is used to specify the character set accepted by the client, which means that any character set can be accepted by default

Accetpt-encoding: Specifies that the Web server that the browser can support returns the content compression encoding type. such as: Accept-encoding:gzip.deflate

Accept-language: Specifies the language that the client can accept. such as: ACCEPT-LANGUAGE:ZH-CN

Authorization: Used to prove that the client has permission to view a resource

Cache-control: Specifies the instructions that all caching mechanisms must obey throughout the request/response chain.

Cache-control Value:

after xxx seconds, the browser re-sends the request to the server
cache-directive Open a new browser window Click the Enter button in the original window refresh Click the Back button
public Browser renders page from cache browser renders page from cache Browser resend request to service Server Browser renders a page from cache
private Browser resend request to servers first time, the browser resend the request to the server After that, the browser renders the page from the cache Browser resend request to server browser renders page from cache
no-cache/no-store Browser Resend request to server Browser Resend request to server Browser Resend request to server Browser Resend request to server
must-revalidation/proxy-revalidation Browser Resend request to server first time, the browser re-sends the request to the server; After that, the browser renders the page from the cache Polygon Browser Resend request to server browser renders page from cache
max-age=xxx (XXX is numeric) after xxx seconds, the browser re-sends the request to the server browser to resend the request to the server after xxx seconds, the browser re-sends the request to the service Service

Connection: Indicates whether a persistent connection is required (HTTP1.1 persistent connection by default). such as: connection:close,connection:keep-alive, means persistent connection

When a cookie:http request is sent, all cookie values stored under that request domain are sent to the Web server

Content-length: The requested content length

Content-type: request MIME information corresponding to the entity

Date: Time and date when the request was sent

Host: Specify the domain name and port number of the requested server

Except: Request a specific server behavior

If-match: The request content matches the entity to be valid

If-modified-since: If the requested part is modified after the specified time, the request succeeds, and the 304 code is returned without modification

Pragma: Used to include specific instructions. such as: Pragma:no-cache

Referer: Contains a URL from which the user accesses the currently requested page from the page represented by the URL.

User-agent: Allows the client to tell the server about its operating system, browser, and other properties


3. Response header


Location: Used to redirect the recipient to a new position

Accept-charset: Indicates whether the server supports the specified range request and what kind of staging request

Age: Estimated time to form from the original server to the proxy cache (in seconds, non-negative

Allow: A valid request behavior for a network resource that is not allowed to return 405. such as: Allow:get, HEAD

Cache-control: Tells whether all caching mechanisms can be cached and which type. such as: Cache-control:no-cache

The return content compression encoding type supported by the Content-encoding:web server. such as: Content-encoding:gzip

Content-language: The language of the response body. such as: Content-language:en,zh

Content-length: The length of the response body. such as: content-length:348

Content-location: The alternate address that the request resource can substitute. such as: content-location:/index.htm

CONTENT-MD5: Returns the MD5 checksum value of a resource

Content-range: The byte position of this section in the entire returned body. such as: Content-range:bytes 21010-47021/47022

Content-type: Returns the MIME type of the content. such as: content-type:text/html; Charset=utf-8

Date: The time the original server message was issued

Expires: The date and time when the response expires.

Pragma: Includes implementation-specific instructions that can be applied to any receiver on the response chain. such as: Pragma:no-cache

Proxy-authenticate: It indicates the authentication scheme and the parameters that can be applied to the proxy on that URL. such as: Proxy-authenticate:basic

Refresh: Indicates how much time the browser should refresh the document, in seconds. such as: Response.setheader ("Refresh", "3"), to achieve the page every 3s refresh once;

Response.setheader ("Refresh", "3;url= '/a/index.html"), implements 3s refresh and jumps to the specified URL

Retry-after: Notifies the client to try again after a specified time if the entity is temporarily undesirable. such as: retry-after:120

Server:web Server Software name. Example: server:apache/1.3.27 (Unix) (Red-hat/linux)

Set-cookie: Set HTTP Cookie

Www-authenticate: Indicates the authorization scheme that the client request entity should use. such as: Www-authenticate:basic






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.