How long may parameters in a get request be?

假装没事ソ 提交于 2019-12-23 07:07:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!