Is there a limit to the length of a GET request? [

2019-01-01 05:22发布

This question already has an answer here:

Is there a limit to the length of a GET request?

6条回答
宁负流年不负卿
2楼-- · 2019-01-01 06:01

W3C unequivocally disclaimed this as a myth here

http://www.w3.org/2001/tag/doc/get7#myths

查看更多
看风景的人
3楼-- · 2019-01-01 06:02

The specification does not limit the length of an HTTP Get request but the different browsers implement their own limitations. For example Internet Explorer has a limitation implemented at 2083 characters.

查看更多
与风俱净
4楼-- · 2019-01-01 06:12

Not in the RFC, no, but there are practical limits.

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 should be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations may not properly support these lengths.

查看更多
何处买醉
5楼-- · 2019-01-01 06:14

This article sums it up pretty well

Summary: It's implementation dependent, as there is no specified limit in the RFC. It'd be safe to use up to 2000 characters (IE's limit.) If you are anywhere near this length, you should make sure you really need URIs that long, maybe an alternative design could get around that.

URIs should be readable, even when used to send data.

查看更多
荒废的爱情
6楼-- · 2019-01-01 06:18

setFixedLengthStreamingMode(int) with contentLength parameters could set the fixed length of a HTTP request body.

查看更多
后来的你喜欢了谁
7楼-- · 2019-01-01 06:20

As Requested By User Erickson, I Post My comment As Answer:

I have done some more testing with IE8, IE9, FF14, Opera11, Chrome20 and Tomcat 6.0.32 (fresh installation), Jersey 1.13 on the server side. I used the jQuery function $.getJson and JSONP. Results: All Browsers allowed up to around 5400 chars. FF and IE9 did up to around 6200 chars. Everything above returned "400 Bad request". I did not further investigate what was responsible for the 400. I was fine with the maximum I found, because I needed around 2000 chars in my case.

查看更多
登录 后发表回答