Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add directive to undo HEAD to GET mapping when output filters exist. #2

Closed
GrahamDumpleton opened this issue May 1, 2014 · 3 comments

Comments

@GrahamDumpleton
Copy link
Owner

If Apache output filters are detected that could care about seeing the actual content for a HEAD, the mod_wsgi will remap a HEAD request to a GET request. This is to ensure that output filters will generate the same response headers where they are generating some based on the actual content. If this isn't done it is technically breaking the HTTP specification that response headers for GET and HEAD should be the same.

Even though this is the case, provide a directive to disable this auto mapping for those people who believe that they aren't using any Apache output filters where this would matter.

See:

Original commentary about the GET vs HEAD problem at:

@lrowe
Copy link

lrowe commented Sep 11, 2014

I have a need for access to the original request method when redirecting to resources on Amazon S3 using query string authentication. My current work around is set the original request method in a different environment variable:

SetEnvIf Request_Method HEAD X_REQUEST_METHOD=HEAD

Then fix up the wsgi environment in my app.

The only problem I've run into is when combining this with an internal redirect, as mod_wsgi sets request->method to GET. That makes sense for PUT or POST, but for HEAD internally redirecting to a HEAD would be more efficient for internal redirects to proxy locations. (Our files include multi-gigabyte raw sequence data.)

@GrahamDumpleton
Copy link
Owner Author

Can you try snapshot of mod_wsgi 4.3.0.

https://github.com/GrahamDumpleton/mod_wsgi/archive/feature/4.3.0.zip

Set the directive:

WSGIMapHEADToGET Off

This can be at VirtualHost scope, or more specific scope such as a Location or Directory block.

Just understand the consequences of doing this if an Apache output filter is present that expects to see the response content, even for a HEAD, to ensure that they match what would be returned for a GET request. If they don't match because of optimisations, then it can confuse caching systems.

@GrahamDumpleton
Copy link
Owner Author

Released in 4.3.0.

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

No branches or pull requests

2 participants