Gangmax Blog

自由之思想,独立之精神

What Is the Maximum Length of a URL

| Comments

From here.

The quick answer is:

  1. From the standard perspective, there is no such limitation.

    RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1 says:

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

  2. For browsers, 2000 characters is the de facto limit.

  3. For curl command, it can send much longer URL than 2000. For the web server, such as Flask, URL longer than 2000 is not a problem.

Here is the code example.

simplehttpserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from flask import Flask
app = Flask(__name__)


@app.route('/')
def hello():
    return "Hello World!"


@app.route('/<name>')
def hello_name(name):
    return "Hello {}!".format(name)

if __name__ == '__main__':
    app.run()

Another fact is, the maximum length of a shell command can be gotten by running the following commandA(from here):

1
2
> getconf ARG_MAX
262144

Comments