Is there a limit to URL length? _PHP Tutorial

WBOY
Release: 2016-07-20 11:17:41
Original
1210 people have browsed it

The reason is that the legendary GET method is transmitted through the URL, and the length of the URL is limited, while the POST method uses a stream, and theoretically there is no limit to the capacity that can be transmitted.

Now look at this description: "The length of the URL is limited." Where is it restricted? On the browser side or on the server side? The results from Google on the Internet now all say that the length of the URL is actually limited. Browser restrictions, such as IE limiting the URL length to 2083 bytes, Opera is 4050, Netscape is 8192, etc. It is said that the HTTP protocol itself has no limit on the length of the GET method. So, if you don’t use a browser, but send HttpRequest from a program, can the length of GET sent be infinite? With this idea in mind, the following experiment was conducted:

On the client side, implemented in Java, send HttpRequest to the server side, using the GET method.

On the server side, design an apache module and use ap_rprintf to output strlen(r->args) as response and return it to the Java side.

By continuously increasing the length of the string passed by the GET method, it is found that when the URL length exceeds 8208 bytes, Java throws IO Exception: Server returned HTTP response code: 414 for URL: .....

What kind of error does 414 represent?

 414 - Request-URL Too Long (SEE: http://www.websitepulse.com/kb/4xx_HTTP_status_codes.html)

It can be seen that the server side has restrictions on the length of the URL, so there are also restrictions on the data that can be transmitted by the GET method. It's just that this limit may depend on the server's processing power, or it's not clear where to configure it. (I started to make wild guesses again, this doesn’t seem to be a good habit).

Now let’s start talking nonsense:

In fact, this is understandable. There is no limit to the URL length. The HTTP protocol is UDP after all, and a UDP packet has a size limit after all. So why can POST transfer large amounts of data? Before trying to read post data in the apache module, I really didn’t have any deep understanding. Just use the word "flow" to describe it. In fact, POST data is read in chunks when parsed. If you understand it from the perspective of UDP, it is divided into multiple UDP packets and passed over, and they are read out one by one.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371949.htmlTechArticleThe reason is that the legendary GET method is passed through the URL, and the length of the URL is limited, and the POST method Using the streaming method, there is no limit to the capacity that can be transferred in theory. Now look at this...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template