I used to think that 1024 bytes (that is, the total length of the URL including the query string), today I heard someone say 256 bytes ...
I tested it and found it was not
FIREFOX,CHROME,IE9, the maximum allowable length is 8193 bytes ...
Questions:
What does this value depend on? According to my test results, three kinds of browsers allow the maximum length of the same, this indicates that should not be a browser problem, that is the server configuration problem? If so, what is the function of the configuration item?
Here is the code for the test:
urllenchk.php
$url = ' http://localhost/lab/urllen.php?query= '; $queryString = Str_repeat (' A ', 8192-strlen ($url) +1); $curl = Curl_init (); curl_setopt ($curl, Curlopt_url, $url. $queryString); curl_setopt ($curl, Curlopt_timeout, ten); Curl_exec ($curl);
urllen.php
echo strlen (' http://'. $_server[' server_name '].$_server[' script_name ']. $_server[' query_string '). "
"; Echo strlen ($_get[' query ');
Reply content:
I used to think that 1024 bytes (that is, the total length of the URL including the query string), today I heard someone say 256 bytes ...
I tested it and found it was not
FIREFOX,CHROME,IE9, the maximum allowable length is 8193 bytes ...
Questions:
What does this value depend on? According to my test results, three kinds of browsers allow the maximum length of the same, this indicates that should not be a browser problem, that is the server configuration problem? If so, what is the function of the configuration item?
Here is the code for the test:
urllenchk.php
$url = ' http://localhost/lab/urllen.php?query= '; $queryString = Str_repeat (' A ', 8192-strlen ($url) +1); $curl = Curl_init (); curl_setopt ($curl, Curlopt_url, $url. $queryString); curl_setopt ($curl, Curlopt_timeout, ten); Curl_exec ($curl);
urllen.php
echo strlen (' http://'. $_server[' server_name '].$_server[' script_name ']. $_server[' query_string '). "
"; Echo strlen ($_get[' query ');
RFC document Form submission method
Get:with the HTTP "Get" method, the form data set is appended to the URI specified by the action attribute (with a questi On-mark ("?") as separator) and this new URI are sent to the processing agent.
Post:with the HTTP "Post" method, the form data set is included in the body of the form and sent to the processing agent.
This does not specify the length of Get and post, and the length limit we see is set by the browser vendor. MSIE is 2k,opera 4 K, Firefox 8K. A 414 error will be returned after exceeding.
For a more detailed discussion of Get and post see article HTTP://STACKOVERFLOW.COM/A/2659995/13 ...
The limit is dependent on both the server and the client used (and if applicable, also the proxy the server or the client is using).
Most webservers has a limit of 8192 bytes (8KB), which is usually configureable somewhere in the server configuration. As to the client side matter, the HTTP 1.1 specification even warns on this, here's an extract of Chapter 3.2.1:
Note:servers ought to being cautious about depending on URI lengths above 255 bytes, because some older client or proxy Impl Ementations might not properly support these lengths.
The limit is in MSIE and Safari on 2KB, in Opera about 4KB and in Firefox about 8KB. We may thus assume that 8KB are the maximum possible length and that 2KB are a more affordable length to rely on at the Serv Er side and that 255 bytes are the safest length to assume that the entire URL would come in.
If the limit is exceeded-either the browser or the server, most would just truncate the characters outside the limit wit Hout any warning. Some servers however may send a HTTP 414 error. If you need to send large data and then better use POST instead of GET. Its limit was much higher, but more dependent on the server used than the client. Usually up to around 2GB are allowed by the average webserver. This is also configureable somewhere in the server settings. The average server would display a server-specific error/exception when the POST limit is exceeded, usually as HTTP-err Or.
RFC 2616 (Hypertext Transfer Protocol http/1.1) Section 3.2.1 has the following description:
The HTTP protocol does not place any a priori limit on the length of
A URI. Servers must is able to handle the URI of any resource they serve, and should is able to handle URIs of unbounded length I F They provide get-based forms that could generate such URIs. A server should return 414 (Request-uri Too Long) status if a URI is longer than the server can handle (see section 10.4.1 5).
Note:servers ought to being cautious about depending on URI lengths above 255 bytes, because some older client or proxy Impl Ementations might not properly support these lengths.
In other words, the protocol itself does not limit the maximum length of the URL, and the server can handle the maximum length as much as possible, otherwise 414 errors are returned.
Another way to configure the URL maximum length in Apache is as follows:
Limitrequestline 4094