Summary of various length constraints in Http

Source: Internet
Author: User
Document directory
  • 1. URL length limit
  • 2. length limit of Post Data
  • 3. Cookie length limit
  • 4. Html5 LocalStorage

 

Http1.0 format

Request (HTTP Request Message)
Structure: A request line. Partial message headers and entity content. Some of the message content is optional. Separate the message header and entity content with empty lines.

GET/index.html HTTP/1.1 // request header. The following are message headers.
Accept :*/*
Accept-inform ang: En-US
Connection: keep-alive
HOST: localhost
Referer: http: // localhost/index.html
User-Agent: Mozilla/4.0
Accept-encoding: gzip, deflate // the header is the message header, and the following blank line indicates the end, followed by the object content.

Response Message Header

After receiving and parsing the request message, the server responds to the message with HTTP. Response from the server to the client's http
Structure: One status line. Some messages

Header and object content, some of which are optional. Separate the message header and object content with blank lines.

HTTP/1.1 OK // status line. The message header is shown below
Server: apache2.2
Date: Thu, 13 Jul 2008 16:29:46 GMT
Content-Length: 2222
Content-Type: text/html
Cache_control: Private // There is an empty line in the same header as the request message.

Note: request messages using the get method cannot contain entity content. Only request messages using the post, put, and delete methods can have entity content. for HTTP1.1, if there is entity content in HTTP, but the chunked Transmission Encoding is not used. the message header must contain the content length field. otherwise, I don't know when the content will end. The host field must be included in HTTP1.1.

Structure of the preceding message header: each message header contains a header field name followed by a colon, a space value, a carriage return, and a line break. The fields are case-insensitive. the headers in the message header can be arranged in any order.
Message Headers can be divided into information headers, request headers, response headers, and object headers.
If there are multiple options, you can use commas to separate Accept-Encoding: gzip, deflate

1. the URL length limit is not specified in Http1.1. It is described in RFC. HTTP does not limit the URI length, the server must be able to process any Uris that can be accepted by the services they provide and can process an infinitely long URI. If the server cannot process too long Uris, it should return a 414 status code. Although the Http protocol stipulates, Web servers and browsers have their own length restrictions on Uris. Server restrictions: the most frequently accessed servers are Nginx and Tomcat. For url length restrictions, they are restricted by controlling the length of the http request header, the nginx configuration parameter is large_client_header_buffers, And the tomcat request configuration parameter is maxHttpHeaderSize, which can be set by yourself. Browser restrictions: Each browser also limits the url length. Below are the url length restrictions for several common browsers: (unit: character) IE: 2803 Firefox: 65536 Chrome: 8182 Safari: 80000 Opera: 190000 for get requests, there is no limit on the number of request parameters within the url length limit. 2. the length limit of Post data is similar to that of url. It is also not specified in Http, the maximum length of the http request header can be configured on the server. 3. Cookie length limit the Cookie length limit is summarized in the following aspects. (1) the maximum number of cookies allowed by the browser in each domain is not tested by the browser. The information found on the internet is probably in this case IE: Originally 20, later, we upgraded to 50 Firefox: 50 Opera: 30 Chrome: 180 Safari: unlimited browser behavior when the number of cookies exceeds the limit: IE and Opera will use the LRU algorithm to clear old and infrequently used cookies. Firefox will randomly kick out some cookies. Of course, no matter what the policy or try not to make the number of cookies exceed the permitted range of the browser. (2) Maximum length of each Cookie allowed by the browser: Firefox and Safari: 4079 bytes Opera: 4096 bytes IE: 4095 bytes (3) limit on the length of Http request headers on the server. The Cookie is attached to the http request header and sent to the server. Therefore, it is also affected by the length of the server request header. 4. html5 LocalStorageHtml5 provides a local storage mechanism for Web applications to store data on the client. Although this is not part of the Http protocol, as Html5 becomes popular, we may need to use LocalStorage more and more, even when it becomes popular, we will deal with it as much as we do with cookies today. For the length limit of LocalStorage, similar to the Cookie limit, it is also the browser's limit on the domain, but the cookie limit is the number, the LocalStorage limit is the length: firefox \ Chrome \ Opera are allowed to each domain Maximum length of 5 MB but this IE is relatively generous, the maximum allowed length is 10 MB original address: http://my.oschina.net/chihz/blog/58057

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.