Reputation: 7011
What is the maximum length of a URL in apache? Where is it documented, and is it configurable?
I'm implementing an openid identity provider, and would like to know the limitations I'm up against. I know about the 2048 byte path limit on Internet Explorer. That can be handled specially using user agent detection. Other browsers have much higher URL limits.
So what I'm interested in is apache server limits when coding an application.
Upvotes: 66
Views: 116784
Reputation: 4062
The default limit for the length of the request line is 8192 bytes = 8* 1024. It you want to change the limit, you have to add or update in your tomcat server.xml the attribut maxHttpHeaderSize.
as:
<Connector port="8080" maxHttpHeaderSize="65536" protocol="HTTP/1.1" ... />
In this example I set the limite to 65536 bytes= 64*1024.
Hope this will help.
Upvotes: -2
Reputation: 1204
Allowed default size of URI is 8177 characters in GET request. Simple code in python for such testing.
#!/usr/bin/env python2
import sys
import socket
if __name__ == "__main__":
string = sys.argv[1]
buf_get = "x" * int(string)
buf_size = 1024
request = "HEAD %s HTTP/1.1\nHost:localhost\n\n" % buf_get
print "===>", request
sock_http = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock_http.connect(("localhost", 80))
sock_http.send(request)
while True:
print "==>", sock_http.recv(buf_size)
if not sock_http.recv(buf_size):
break
sock_http.close()
On 8178 characters you will get such message: HTTP/1.1 414 Request-URI Too Large
Upvotes: 5
Reputation: 26547
Here's a bash script to check the maximum limit of a remote server (uses curl and perl).
You just need some kind of an url that can be extended with 'x' and always return 200 (or adapt it to your needs). At some point it will break and the script will display the max length.
Here's the code:
url='http://someurl/someendpoint?var1=blah&token='
ok=0
times=1
while :; do
length=$((times+${#url}))
echo trying with $length
token=$(perl -le 'print "x"x'$times)
result=$(curl -sLw '%{http_code}' -o /dev/null "${url}${token}")
if [[ $result == 200 ]]; then
if [[ $ok == $times ]]; then
echo "max length is $length"
break
fi
ok=$times
times=$((times+1024))
else
times=$(((times+ok)/2))
fi
done
Upvotes: 4
Reputation: 655785
The default limit for the length of the request line is 8190 bytes (see LimitRequestLine
directive). And if we subtract three bytes for the request method (i.e. GET
), eight bytes for the version information (i.e. HTTP/1.0
/HTTP/1.1
) and two bytes for the separating space, we end up with 8177 bytes for the URI path plus query.
Upvotes: 77
Reputation: 6860
From: http://www.danrigsby.com/blog/index.php/2008/06/17/rest-and-max-url-size/
Upvotes: 19
Reputation: 545
The official length according to the offical Apache docs is 8,192, but many folks have run into trouble at ~4,000.
MS Internet Explorer is usually the limiting factor anyway, as it caps the maximum URL size at 2,048.
Upvotes: 7