PDF paths not detected under FastCGI #112

Closed
Floppy opened this Issue Sep 13, 2011 · 1 comment

2 participants

@Floppy

I'm using a Rails 2.3.11 app with Apache/FastCGI (I'd rather not, but there it is), and am trying to use the PDFKit Rack middleware.

In order to work out if it needs to process it, PDFKit parses the env into a Rack::Request object (https://github.com/jdpace/PDFKit/blob/master/lib/pdfkit/middleware.rb#L12) and then checks to see if request.path ends in .pdf.

However, if I request /controller/action.pdf, under FastCGI, Rack::Request#path returns /dispatch.fcgi, NOT the requested URI, because it uses env"SCRIPT_NAME".

When running under WEBrick, Rack::Request#path returns /controller/action.pdf because it also uses env["PATH_INFO"]. Apache doesn't set this one, but instead sets REQUEST_URI.

I'm not sure if this is a bug in Rack, FastCGI, or PDFKit. What do you think?

As Rack::Request#path is not consistent under different server configurations, PDFkit should probably not be relying on Rack::Request#path to get the requested URI. I have fixed it by using request.env['REQUEST_URI'] instead of request.path in the PDFKit code, but I'm not sure that's really a good fix.

Any ideas?

@sigmavirus24
pdfkit member

Is this still an issue? If not please close it.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment