PHP Knowledge Point 0-http Head

Source: Internet
Author: User
Tags md5 digest ranges response code



1.HTTP Head Explanation
(1) Accept: Tell the Web server what type of media it accepts, */* represents any type, type/* represents all sub-types under that type, Type/sub-type.


(2) Accept-charset: The browser affirms the character set it receives
Accept-encoding: The browser declares itself to receive the encoding method, usually specifies the compression method, whether compression is supported, what compression method is supported (Gzip,deflate)
Accept-language:: The browser affirms that the language you receive differs from the character set: Chinese is language, Chinese has multiple character sets, such as BIG5,GB2312,GBK and so on.


(3) The Accept-ranges:web server indicates whether it accepts requests to obtain a portion of its entity, such as a portion of a file. Bytes: Accept, none: Indicates not accepted.


(4) Age: When the proxy server responds to a request with its own cached entity, it uses that header to indicate how long it has been from the time it was generated to the present.


(5) Authorization: When the client receives a www-authenticate response from the Web server, the header responds to its own authentication information to the Web server.


(6) Cache-control: Request: No-cache (do not cache the entity, request now from the Web server to fetch)
Max-age: (Accept only the age value is less than the Max-age value, and there are no expired objects)
Max-stale: (Can accept past objects, but the expiration time must be less than
Max-stale value)
Min-fresh: (accepting that its freshness is greater than the sum of its current age and Min-fresh values
Cache objects)
Response: Public (can respond to any user with Cached content)
Private (only cached content can be used to respond to the user who previously requested the content)
No-cache (can be cached, but only after the Web server has verified that it is valid to be returned to the client)
Max-age: (The expiration time of the object contained in this response)
All:no-store (cache not allowed)


(7) Connection: Request: Close (tells the Web server or proxy server to complete the response to this request
, disconnect and do not wait for subsequent requests for this connection).
KeepAlive (Tell the Web server or proxy server to complete this request
After the response, remain connected, waiting for subsequent requests for this connection).
Response: Close (the connection is closed).
KeepAlive (connection is maintained, waiting for subsequent requests for this connection).
Keep-alive: If the browser requests to remain connected, the header indicates that you want the WEB server to remain
How long to connect (in seconds).
Example: keep-alive:300


(8) The Content-encoding:web server indicates what compression method (Gzip,deflate) It uses to compress the objects in the response.
Example: Content-encoding:gzip
The Content-language:web server tells the browser the language of the object it responds to.
The Content-length:web server tells the browser the length of the object it responds to.
Example: content-length:26012
The Content-range:web server indicates that the response contains part of the object that is the entire object.
Example: Content-range:bytes 21010-47021/47022
The Content-type:web server tells the browser what type of object it responds to.
Example: Content-type:application/xml


(9) ETag: Is the flag value of an object, such as a URL, for an object, such as an HTML file,
If it is modified, its etag will not be modified, so the role of the ETag with last-modified
function, mainly for the WEB server to determine whether an object has changed.
For example, when a previous request for an HTML file, the ETAG was obtained, and when the file was requested this time,
The browser sends the previously acquired ETAG value to the Web server, and the Web server
Compares the etag to the current etag of the file and then knows that the file
There has been no change.


(10) The Expired:web server indicates when the entity will expire, and for expired objects, only the
After the Web server has verified its validity, it can be used to respond to customer requests.
It's http/1.0 's head.
Example: Expires:sat, 10:02:12 GMT


(11) Host: The client specifies the domain/IP address and port number of the Web server that you want to access.
Example: Host:rss.sina.com.cn


(12) If-match: If the ETag of an object does not change, it actually means that the object has not changed before performing the requested action.
If-none-match: If the ETag of an object changes, it also means that the object has changed to perform the requested action.


(13) If-modified-since: If the requested object is modified after the specified time in the header, the request is executed
(For example, return object), or return code 304, telling the browser that the object
Not modified.
Example: If-modified-since:thu, APR 09:14:42 GMT
If-unmodified-since: If the requested object has not been modified since the time specified in the header, the
The requested action (such as returning an object).


(14) If-range: The browser tells the WEB server that if the object I requested does not change, put my missing part
Give me, if the object has changed, give me the whole object. Browser by sending the request object's
The ETag or the last modification time you know to the WEB server to determine if the object
Has changed.
Always used with the Range header.


(15) Last-modified:web server considers the last modification time of the object, such as the last modification time of the file,
The last generation time of the dynamic page, and so on.
For example: Last-modified:tue, May 02:42:43 GMT


(16) The Location:web server tells the browser that the object you are trying to access has been moved to another location,
To the location specified in the header.
For example: Location:
Http://i0.sinaimg.cn/dy/deco/2008/0528/sinahome_0803_ws_005_text_0.gif


(17) PRAMGA: The main use of pramga:no-cache, equivalent to Cache-control:no-cache.
Example: Pragma:no-cache


(18) Proxy-authenticate: The proxy server responds to the browser and requires it to provide proxy authentication information.
Proxy-authorization: The browser responds to the proxy server's authentication request and provides its own identity information.


(19) Range: A browser (such as Flashget multithreaded download) tells the WEB server what part of the object it wants to take.
Example: range:bytes=1173546-


(20) Referer: The browser indicates to the Web server which page/url obtained/clicked on the URL/url in the current request.
Example: referer:http://www.sina.com/


(21) Server:web server indicates what kind of software and version of the information.
Example: server:apache/2.0.61 (Unix)


(22) User-agent: The browser indicates its identity (which browser).
For example: user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; ZH-CN;
rv:1.8.1.14) gecko/20080404 firefox/2.0.0.14


(23) Transfer-encoding:web server indicates itself to the body of this response message (not the object inside the message body)
What kind of code, such as whether it is chunked (chunked).
Example: transfer-encoding:chunked


(24) The Vary:web server uses the contents of the header to tell the Cache server under what conditions it can use this response
The returned object responds to subsequent requests.
If the source Web server receives the first request message, the header of its response message is:
Content-encoding:gzip; Vary:content-encoding then the Cache server will analyze subsequent
Request the header of the message, check its accept-encoding, and the Vary header value of the previous response
Consistent, that is, whether to use the same content encoding method, so that the Cache server can prevent the use of their own
The compressed entity in the Cache responds to browsers that do not have the ability to decompress.
Example: vary:accept-encoding


(25) Via: Lists which proxy servers The response from the client to the OCS or in the opposite direction
The Protocol (and version) of the request sent.
When a client request arrives at the first proxy server, the server is in a request made by itself
Add Via header and fill in your relevant information when the next proxy server receives the first proxy
Request from the server, the request from the previous proxy server will be copied via
Head, and add their relevant information to the back, and so on, when OCS receives the last proxy service
Check the Via header, you know the route through which the request was routed.
Example: via:1.0 236-81.d07071953.sina.com.cn:80 (SQUID/2.6.STABLE13)


2.HTTP Request message Header instance:
Host:rss.sina.com.cn
user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; ZH-CN; rv:1.8.1.14) gecko/20080404 firefox/2.0.0.14
accept:text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
accept-language:zh-cn,zh;q=0.5
Accept-encoding:gzip,deflate
accept-charset:gb2312,utf-8;q=0.7,*;q=0.7
keep-alive:300
Connection:keep-alive
COOKIE:USERID=C5BYPXRIMDMSIQMSBPNE1VN8ZQMDWSM3WRLEB3VRWTNRTW <--Cookies
If-modified-since:sun, June 12:05:30 GMT
Cache-control:max-age=0
HTTP Response message Header instance:
The status:ok-200 <--response status code that represents the result of the Web server processing.
Date:sun, June 12:35:47 GMT
server:apache/2.0.61 (Unix)
Last-modified:sun, June 12:35:30 GMT
Accept-ranges:bytes
content-length:18616
cache-control:max-age=120
Expires:sun, June 12:37:47 GMT
Content-type:application/xml
Age:2
X-cache:hit HTTP headers used by the reverse proxy server from 236-41.d07071951.sina.com.cn <--
via:1.0 236-41.d07071951.sina.com.cn:80 (SQUID/2.6.STABLE13)
Connection:close


3.HTTP Head Information Simple description
The 3.1.HTTP Response Code Response code consists of three-bit decimal digits that appear in the first line of the response sent by the HTTP server.
The response code is divided into five types, denoted by their first digit:
1XX: Information, request received, continue processing
2XX: Success, Behavior is successfully accepted, understood and adopted
3xx: Redirect, in order to complete the request, the action must be further performed
4XX: Client error, request contains syntax error or request cannot be implemented
5XX: Server error, server cannot implement an apparently invalid request
The following table shows each response code and what it means:
100 Continuation 101 Packet Exchange co-OK201 was created 202 adopted 203 non-authorized information 204 no content 205 Reset content 206
Section 300 multiple Options 301 permanently transfer 302 found 303 see other 304 unchanged 305 use proxy 307 temporarily redirect 400
Error request 401 Unauthorized 402 request fee 403 Forbidden 404 Not Found 405 disallowed method 406 Not accepted 407 Request Proxy Authorization 408
Request Timeout 409 conflict 410 expired 411 required length 412 premises not established 413 request instance too large 414 request URI too large 415
Unsupported media type 416 cannot meet the request range 417 failed expected 500 internal server error 501 is not used 502
Gateway error 503 Unavailable Service 504 Gateway Timeout 505 HTTP version not supported


The 3.2.HTTP header header is composed of a primary key/value pair. They describe the properties of the client or server, the resources being transferred, and the connection that should be implemented.
Four different types of head labels:
(1) Generic header: Can be used for a request or for a response, and is associated with a transaction as a whole rather than a specific resource.
(2) Request header: Allows the client to pass information about itself and the form of the desired response.
(3) Response header: The server and the response to transmit its own information.
(4) Entity header: Defines information about the transmitted resource. Can be used for requests or for responses.


Header Format:<name>:<value><crlf>


The following table describes the headers used in the http/1.1
Accept defines the types of media that clients can handle, sorted by priority; In a comma-delimited list, you can define multiple types
and wildcard characters are used. For example: Accept:image/jpeg,image/png,*/*accept-charset defines the character set that the client can handle,
Sort by priority; In a comma-delimited list, you can define multiple types and use wildcards.
Example: Accept-charset:iso-8859-1,*,utf-8
Accept-encoding defines the encoding mechanism that the client can understand. Example: accept-encoding:gzip,compress
Accept-language defines a list of natural languages that the client is willing to accept. Example: Accept-language:en,de
Accept-ranges a response header that allows the server to indicate that it will accept requests for the resource component at a given offset and length.
The value of the header is understood as the unit of measure for the requested range. such as Accept-ranges:bytes or Accept-ranges:none
Age allows the server to specify the length of time, in seconds, that has elapsed since the server generated the response. The header is used primarily for caching responses.
Example: age:30
Allow a response header that defines a list of HTTP methods supported by the Zhiyuan in the request URI. Example: Allow:get,put
AUTHORIZATION a response header that defines the authorization (domain and encoded user ID and password) necessary to access a resource.
Example: Authorization:basic yxv0ag9yonboaww=
Cache-control a generic header for defining cache directives. Example: cache-control:max-age=30
Connection a generic header that indicates whether the socket connection is saved as open. Example: Connection:close or Connection:keep-alive
Content-base an entity header that defines a base URI in order to resolve relative URLs within the entity scope. If the content-base header is not defined
To resolve relative URLs, use the content-location URI (present and absolute) or use a URI request. For example: content-base:


Content-encoding a type of media modifier that indicates how an entity is encoded. Example: Content-encoding:zipcontent-language
Used to specify the natural language type of the data in the input stream. Example: Content-language:en
CONTENT-LENGTH Specifies the length of the bytes contained in the request or response data. Example: content-length:382
CONTENT-LOCATION Specifies the resource location (URI) contained in the request or response. If it is a must. To the URL it also acts as the parsed entity
The starting point of the relative URL. Example: Content-location:http://www.myweb.com/news
A MD5 Digest of the CONTENT-MD5 entity used as a checksum. Both the sender and the receiver calculate the MD5 summary, and the receiver calculates the value with the
The value passed in this header is compared. Example: content-md5: <base64 of MD5 digest>
The Content-range is sent along with some entities, indicating the low and high byte offsets of the inserted bytes, as well as the total length of the entity.
Example: content-range:1001-2000/5000
Contern-type indicates the MIME type of the entity being sent or received. Example: content-type:text/html
Date when the HTTP message was sent. Example: DATE:MON,10PR 18:42:51 GMT
ETag an entity header that assigns a unique identifier to the resource being sent. For resources that can use multiple URL requests, the ETAG
Can be used to determine whether the actual resource being sent is the same resource. For example: ETag: ' 208f-419e-30f8dc99 '
Expires the validity period of the specified entity. Example: expires:mon,05 Dec 12:00:00 GMT
form a request header, given the e-mail address of the human user who controls the user agent. For example: from: [email protected]
Host name of the resource being requested by host. This domain is mandatory for requests that use http/1.1. Example: Host:www.myweb.com


If-modified-since If a GET request is included, the request is conditionally dependent on the last modified date of the resource. If this header appears,
And since the specified date, this resource has been modified and should be reversed back to a 304 response code. Example: IF-MODIFIED-SINCE:MON,10PR 18:42:51 GMT
If-match if included in a request, specify one or more entity tags. Only the resources whose etag is labeled with the list are sent.
Example: If-match: ' 208f-419e-308dc99 '
If-none-match If a request is included, specify one or more entity tags. The etag of the resource does not match any one of the criteria in the list.
Operation is not performed. Example: If-none-match: ' 208f-419e-308dc99 '
If-range an entity tag for the specified resource, and the client already has a copy of this resource. Must be used in conjunction with the range header.
If this entity has not been modified since it was last retrieved by the client, the server sends only the specified range, otherwise it will send an entire
A resource. Example: Range:byte=0-499<crlf>if-range: ' 208f-419e-30f8dc99 '
If-unmodified-since This entity is returned only if the requested entity has not been modified since the specified date.
Example: IF-UNMODIFIED-SINCE:MON,10PR 18:42:51 GMT
last-modified Specifies the date and time that the requested resource was last modified. Example: LAST-MODIFIED:MON,10PR 18:42:51 GMT


Location for a resource that has already been moved, it is used to redirect the requestor to another position. With status Code 302 (temporarily moved)
or 301 (permanent movement) in conjunction with. Example: location:http://www2.myweb.com/index.jsp
Max-forwards a request header for the trace method to specify the maximum number of proxies or gateways that the request is routed through the gateway.
The proxy or gateway should reduce this number before passing the request. Example: Max-forwards:3
Pragma a generic header that sends implementation-related information. Example: Pragma:no-cache
Proxy-authenticate is similar to Www-authenticate, which is intentionally requesting authentication from the next server only from the request chain (proxy).
Example: Proxy-authenticate:basic realm-admin
Proxy-proxy-authorization is similar to authorization, but does not intentionally deliver anything that is further than the instant server chain.
Example: Proxy-proxy-authorization:basic yxv0ag9yonboaww=
The public list shows the set of methods supported by the server. Example: Public:options,mget,mhead,get,head


range specifies the offset range of a unit of measure and a partially requested resource. Example: range:bytes=206-5513
Refener a Request header field that indicates the initial resource that generated the request. For an HTML form, it contains the address of the Web page for this form.
Example: refener:http://www.myweb.com/news/search.html
Retry-after a response header domain that is sent by the server with a status code of 503 (unable to provide a service) to indicate before the request again
How long should you wait. This time can be a date, or it can be a unit of seconds. Example: retry-after:18
Server A header that identifies the Web server software and its version number. Example: server:apache/2.0.46 (WIN32)
Transfer-encoding a generic header that indicates the type of transformation that corresponds to the message body that is reversed by the receiving party.
Example: transfer-encoding:chunked
Upgrade allows the server to specify a new protocol or a new protocol version, which is used in conjunction with response Encoding 101 (switching protocol).
Example: upgrade:http/2.0
User-agent defines the type of software used to generate the request (typically, such as a Web browser).
For example: user-agent:mozilla/4.0 (compatible; MSIE 5.5; Windows NT; Digext)
Vary a response header that is used to indicate that a response entity is selected from the available response representations using server-driven negotiation.
For example: Vary: *via A generic header with all intermediate hosts and protocols to satisfy the request.
Example: via:1.0 fred.com, 1.1 wilma.com
The Warning is used to provide a response header for response status supplemental information. Example: warning:99 www.myweb.com Piano needs tuning
Www-authenticate a response header that prompts the user agent to provide a user name and password, which is used in conjunction with status Code 401 (not authorized).
Responds to an authoritative header. Example: Www-authenticate:basic realm=zxm.mgmt

PHP Knowledge Point 0-http Head

Related Article

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.