Why does my request line limit in Apache seem not to equal the default limit?

I’m developing a local-only PHP application. It uses URLs to transfer data between its states. Accordingly, I wanted to check how much data can be transferred.

Now, I know browsers can have their own limits, so that’s another story. In this question I’m focusing on the server. I’m using Apache HTTP Server 2.4.41.

With trial and error, I was able to determine that when I do this:

curl -I "http://localhost?$( head -c 8175 /dev/zero | tr '' a )"

I get this:

HTTP/1.1 200 OK

And when I do this:

curl -I "http://localhost?$( head -c 8176 /dev/zero | tr '' a )"

(one byte more) I get this:

HTTP/1.1 414 Request-URI Too Long

Initially I didn’t know what “Request-URI” is. I determined it examining

During the examination, I got to know that there’s the thing “request line” (“Request-Line”?), and that Apache limits it to 8190 bytes by default.

I then did this:

tail -n1 /var/log/apache2/access.log |
    gawk -F" '{ printf "%s", $2; }' |
    wc -c

And got this:

8191

This means the limit of my request line. We see there’s 1 byte of difference.

Neither /etc/apache2/apache2.conf nor /etc/apache2/sites-available/000-default.conf contains the LimitRequestLine directive.

Why the difference? Am I missing something?


I see I’ve failed to describe which request line has the length 8191. It can’t be determined looking only at the tail… command. Consequently, it might be assumed that I made a mistake by measuring the request line with the longer payload (8176). This would explain the difference. But I now checked again:

  1. Ran the curl… command with the shorter payload.
  2. In the log entry, checked the status code of the response, and the date and time.
  3. Measured the length of the request line.

I can confirm that it’s the request line with the shorter payload (8175) that has the length of 8191.

If one knows a way to confirm that with one simple command, please let me know. E.g. I’m not sure if curl can return just the request line, without any newlines and the like prepended or appended.