Forum Bugs

Bug: Prince not setting HTTP_REFERRER correctly.

cletus
To get around the problem of using absolute URIs for my CSS and image files (meaning Prince can resolve relative URIs relative to the current directory but not absolute URIs), I have set a base URL for Prince. The problem is that on css/images I'm setting 403 errors: its falling afoul of my hotlinking config for Apache. I can only assume this is because the HTTP_REFERRER isn't set or is set incorrectly?

Can someone please clarify what the expected behaviour is?
mikeday
That's a good point, if the file is local then the referer (sic) will not be a HTTP URL, even if a different base URL has been set. How does the browser handle this? If you access your HTML page as a local file with the browser, and you set the base URL using a <base href="..."> element in the page head, does the browser successfully get the images?
cletus
Might I suggest simply setting HTTP_REFERRER to whatever the base URL is? Well the host part anyway.
tholland
Where can you set the HTTP_REFERRER for Prince?

After working for a couple of months, my automated generation script (which runs from a .net shell calling Prince against html source files that are generated at run time using Jaxer and served by a local Apache instance) stopped working - only noticed it today.

The logs are showing some sort of error to do with invalid referrer info, so I'd like to get that fixed. I can seemingly run the same call as is being scripted manually with success, so it might not be the solution... but worth ruling out.
mikeday
If the file is being accessed over HTTP, then the referer should be set correctly for any referenced images or style sheets. What is the error that you are getting?
tholland
Variations of the following (many with no details):

[Wed Nov 25 07:30:50 2009] [error] [client 127.0.0.1] request failed: error reading the headers, referer: 8\x82
[Wed Nov 25 07:30:50 2009] [error] [client 127.0.0.1] request failed: error reading the headers, referer: 8\x82
[Wed Nov 25 07:30:50 2009] [error] [client 127.0.0.1] request failed: error reading the headers, referer: H\xe6

Also seeing some of these, but thought I'd start with the one that was most clear.

[Wed Dec 02 17:51:39 2009] [error] [client 127.0.0.1] Invalid URI in request Cookie: JaxerSessionId%24%24localhost%3A8081=125980509272607846058018136213
mikeday
Looks like the document URL has some funny characters in it that are getting incorrectly encoded in the referer field when subsequent HTTP requests are made for images or style sheets. Are there any non-ASCII characters in the URL?