问题
I am currently programming an API that gets passed data via get parameters so I was wondering if the total length of the URL or of the parameters value is limited in best practice or by the protocol.
回答1:
Basically, 2K is the most you can rely on in a cross-browser fashion, but if you drop support for IE 8 and below, you can get to like 64K.
Although I feel I need to question your need to know this, anything over say.. 100 characters would best be handled through a POST request instead of a GET.
回答2:
Just to add the canonical reference... from the HTTP 1.1 RFC, in section 3.2.1:
The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if 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.15).
Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.
回答3:
There is no official limit, so its at the mercy of the different browsers.
来源:https://stackoverflow.com/questions/6205479/how-long-may-parameters-in-a-get-request-be