[Interview not answered questions 1]http request, what information does the request header and the response header have?

Source: Internet
Author: User
Tags ranges

Tag: Range tells response res data request Identity Order ICA

Recently in the search for a job, the interviewer asked some questions himself did not answer on, here to do a summary.

  What information does the HTTP request, the request header and the response header have?

  The most common way for page and server interaction is to Ajax,ajax simply that the browser sends the request to the service side and then the service side returns the data, as shown in the common request headers and response headers.

  

See general information First, general information has three fields: request URL, request method, status code, remote address.

  Look at the request Headers,

Accept: Specifies the type of content that the client can receive, and the order in which the content type represents the order in which the client receives it. In AJAX code, you can use the setRequestHeader function method in the XMLHttpRequest object to dynamically set these header information.

Accept-encoding: Specifies that the Web server that the client browser can support returns the content compression encoding type. Indicates that the server is allowed to compress the output before it is sent to the client to conserve bandwidth. The return compression format that the client browser can support is set here.

Accept-language: Specifies the preferred language for the HTTP client browser to display the return information.

Connection: Indicates whether a persistent connection is required. If the Web server side sees the value here as "keep-alive", or sees the request using an HTTP 1.1 (HTTP 1.1 By default for persistent connection), it can take advantage of the persistent connection, when the page contains multiple elements (such as applets, pictures), Significantly reduce the time it takes to download. To do this, the Web server needs to send a content-length (the length of the message body) header back to the client HTTP header, and the simplest implementation is to write the content to Bytearrayoutputstream first, and then Calculates the size of the content before it is formally written.

Connec-length: The length of the request header.

Connect-type: Displays the content type submitted by this HTTP request. This property is typically only required for post submission.

There are two types of encoding available for the Content-type property values:

(1) "application/x-www-form-urlencoded": the type of encoding used when the form data is submitted to the server, the default value is "application/x-www-form-urlencoded". However, this encoding is inefficient when sending large amounts of text to the server, including text or binary data that contains non-ASCII characters.

(2) "Multipart/form-data": When the file is uploaded, the type of encoding used should be "Multipart/form-data", which can both send text data and support binary data upload.

You can use "application/x-www-form-urlencoded" when committing to data alone, and when you commit a file, you need to use the "multipart/form-data" encoding type.

The charset character encoding of the commit content is also specified in the Content-type property. Typically not set, it simply tells the Web server what character encoding to use for the data submitted by the post.

Cookies: Browser-side cookies.

Hose: Client Address

Origin: Destination Address

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

User-agent: Client Information

X-requested-with: Whether it is a synchronous request, or an Ajax asynchronous request if it is XMLHttpRequest. If NULL is a traditional synchronous request

  Response Header Response Header

  Because the returned fields in the instance are not very full, the more comprehensive data is found on the network

Accept-ranges Indicates whether the server supports the specified range request and what kind of staging request Accept-ranges:bytes
Age Estimated time (in seconds, non-negative) from the original server to the proxy cache Age:12
Allow A valid request behavior for a network resource is not allowed to return 405 Allow:get, HEAD
Cache-control Tell if all caching mechanisms can be cached and which type Cache-control:no-cache
Content-encoding The type of return content compression encoding supported by the Web server. Content-encoding:gzip
Content-language The language of the response body Content-language:en,zh
Content-length The length of the response body content-length:348
Content-location Alternate alternative address to request resource substitution Content-location:/index.htm
Content-md5 Returns the MD5 checksum value of a resource content-md5:q2hly2sgsw50zwdyaxr5iq==
Content-range The byte position of this section in the entire return body Content-range:bytes 21010-47021/47022
Content-type Returns the MIME type of the content content-type:text/html; Charset=utf-8
Date Time the original server message was issued Date:tue, 08:12:31 GMT
ETag The current value of the entity label of the request variable ETag: "737060cd8c284d8af7ad3082f209582d"
Expires Date and time when the response expires Expires:thu, 16:00:00 GMT
Last-modified Requested last modified time for resource Last-modified:tue, 12:45:26 GMT
Location Used to redirect the receiver to the location of the non-request URL to complete the request or identify the new resource Location:http://www.zcmhi.com/archives/94.html
Pragma Includes implementing a specific instruction that can be applied to any receiver on the response chain Pragma:no-cache
Proxy-authenticate It indicates the authentication scheme and the parameters on the URL that can be applied to the proxy Proxy-authenticate:basic
Refresh Applied to redirect or a new resource was created, redirected after 5 seconds (proposed by Netscape, supported by most browsers)

Refresh:5; Url=http://www.zcmhi.com/archives/94.html

Retry-after Notifies the client to try again after a specified time if the entity is temporarily undesirable retry-after:120
Server Web Server Software Name server:apache/1.3.27 (Unix) (Red-hat/linux)
Set-cookie Set HTTP Cookies Set-cookie:userid=johndoe; max-age=3600; Version=1
Trailer Indicates that the header domain is present at the end of the chunked transfer code Trailer:max-forwards
Transfer-encoding File transfer encoding Transfer-encoding:chunked
Vary Tells the downstream agent whether to use the cache response or request from the original server Vary: *
Via Tells the proxy client where the response was sent by via:1.0 Fred, 1.1 nowhere.com (apache/1.1)
Warning Warning about possible issues with the entity warning:199 Miscellaneous Warning
Www-authenticate Indicates the authorization scheme that the client request entity should use Www-authenticate:basic

[Interview not answered questions 1]http request, what information does the request header and the response header have?

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.