I’ve been getting this error using Apache as a reversed proxy for my Apache Tomcat server, whenever I try to download a corrupted PDF the response of the server is empty and I get this on the Apache logs:
AH01328: Line too long, URI /uri/moreruri/docNum, referer: https://example.com/uri/moreruri/docNum
I’ve tried to get the same error on my local server (again with Apache and Apache Tomcat) and it is not happening.
Any ideas why this could be happening? Thanks in advance.
2
Answers
This error was happening because of this line in the
/conf/httpd.conf
configuration file:Here what Apache tries to do is, whenever a GET is done and that GET is returning a PDF file, it tries to read the file and substitute specific strings of text.
Those substitutions are defined at this line:
When apache receives the GET and sees that we're requesting a PDF file, it tries to read it and substitute those strings, however as the file is corrupt, apache cannot read it.
It then throws all the PDF content into a single line inside the body of the response, which happens to be (at our specific case), bigger than the default maximum line length (measured in MB).
This causes the response to be cut, and what we got finally was an empty response.
We also had this line:
It changes the default maximum line length, however our file weighted 20MB and here we're setting the maximum length to 5MB, thus not covering for this specific case.
Our solution to the problem was to simply remove the first line, as we didn't need to change PDF's contents:
You may want, however to change the maximum length using this line:
I would not advise to do that though because the limit is lower by default for security reasons.
If use Appache server, add this to .httaccess file: