Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How long may parameters in a get request be?

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.

like image 525
Dominik Avatar asked Jun 01 '11 17:06

Dominik


People also ask

How long can GET parameters be?

If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path. However, the POST method is not limited by the size of the URL for submitting name/value pairs.

How large can a GET request be?

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.

Can a GET request have parameters?

GET requests don't have a request body, so all parameters must appear in the URL or in a header. While the HTTP standard doesn't define a limit for how long URLs or headers can be, mostHTTP clients and servers have a practical limit somewhere between 2 kB and 8 kB.

How long can URL parameters be?

The official documentation specifies a maximum length of 2048 characters for the <loc> element, which is used to submit URLs: URL of the page. This URL must begin with the protocol (e.g. “http”) and end with a trailing slash if required by the web server. This value must not exceed 2,048 characters.


2 Answers

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.

like image 137
Blindy Avatar answered Sep 28 '22 06:09

Blindy


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.
like image 40
JaredReisinger Avatar answered Sep 28 '22 06:09

JaredReisinger