Maximum length of HTTP GET request

Web ServicesHttp

Web Services Problem Overview


What's the maximum length of an HTTP GET request?

Is there a response error defined that the server can/should return if it receives a GET request that exceeds this length?

This is in the context of a web service API, although it's interesting to see the browser limits as well.

Web Services Solutions


Solution 1 - Web Services

The limit is dependent on both the server and the client used (and if applicable, also the proxy the server or the client is using).

Most web servers have a limit of 8192 bytes (8 KB), which is usually configurable somewhere in the server configuration. As to the client side matter, the HTTP 1.1 specification even warns about this. Here's an extract of chapter 3.2.1:

> 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.

The limit in Internet Explorer and Safari is about 2 KB, in Opera about 4 KB and in Firefox about 8 KB. We may thus assume that 8 KB is the maximum possible length and that 2 KB is a more affordable length to rely on at the server side and that 255 bytes is the safest length to assume that the entire URL will come in.

If the limit is exceeded in either the browser or the server, most will just truncate the characters outside the limit without any warning. Some servers however may send an HTTP 414 error.

If you need to send large data, then better use POST instead of GET. Its limit is much higher, but more dependent on the server used than the client. Usually up to around 2 GB is allowed by the average web server.

This is also configurable somewhere in the server settings. The average server will display a server-specific error/exception when the POST limit is exceeded, usually as an HTTP 500 error.

Solution 2 - Web Services

You are asking two separate questions here:

> What's the maximum length of an HTTP GET request?

As already mentioned, HTTP itself doesn't impose any hard-coded limit on request length; but browsers have limits ranging on the 2 KB - 8 KB (255 bytes if we count very old browsers).

> Is there a response error defined that the server can/should return if it receives a GET request exceeds this length?

That's the one nobody has answered.

HTTP 1.1 defines status code 414 Request-URI Too Long for the cases where a server-defined limit is reached. You can see further details on [RFC 2616][1].

For the case of client-defined limits, there isn't any sense on the server returning something, because the server won't receive the request at all.

[1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.15 "RFC 2616"

Solution 3 - Web Services

Browser limits are:

Browser           Address bar    document.location
                                 or anchor tag
---------------------------------------------------
Chrome                32779           >64k
Android                8192           >64k
Firefox                >64k           >64k
Safari                 >64k           >64k
Internet Explorer 11   2047           5120
Edge 16                2047          10240

Want more? See this question on Stack Overflow.

Solution 4 - Web Services

A similar question is here: https://stackoverflow.com/questions/266322/http-uri-get-limit

I've hit the limit and on my shared hosting account, but the browser returned a blank page before it got to the server I think.

Solution 5 - Web Services

Technically, I have seen HTTP GET will have issues if the URL length goes beyond 2000 characters. In that case, it's better to use HTTP POST or split the URL.

Solution 6 - Web Services

As already mentioned, HTTP itself doesn't impose any hard-coded limit on request length; but browsers have limits ranging on the 2048 character allowed in the GET method.

Solution 7 - Web Services

GET REQUEST using the Chrome browser

Yes. There isn't any limit on a GET request.

I am able to send ~4000 characters as part of the query string using both the Chrome browser and curl command.

I am using Tomcat 8.x server which has returned the expected 200 OK response.

Here is the screenshot of a Google Chrome HTTP request (hiding the endpoint I tried due to security reasons):

RESPONSE

GET using the Chrome browser

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMark HarrisonView Question on Stackoverflow
Solution 1 - Web ServicesBalusCView Answer on Stackoverflow
Solution 2 - Web ServicesEdurne PascualView Answer on Stackoverflow
Solution 3 - Web ServicesJiraff537View Answer on Stackoverflow
Solution 4 - Web ServicesjayView Answer on Stackoverflow
Solution 5 - Web ServicesMSIslamView Answer on Stackoverflow
Solution 6 - Web ServicesSandeep KumarView Answer on Stackoverflow
Solution 7 - Web ServicesLokendra ChauhanView Answer on Stackoverflow