开发者

How long may parameters in a get request be?

开发者 https://www.devze.com 2023-03-10 05:25 出处:网络
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

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.


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.


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.


There is no official limit, so its at the mercy of the different browsers.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号