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

WSGI handler not updating status code #53

Closed
elliottwilliams opened this issue May 13, 2016 · 0 comments
Closed

WSGI handler not updating status code #53

elliottwilliams opened this issue May 13, 2016 · 0 comments

Comments

@elliottwilliams
Copy link

I've been having trouble getting my wsgi application (in this case, Django) to change the status code of the Apache response, and I think it might due to a bug with mod_python. I wrote a simple wsgi handler to confirm: no matter what status string is passed into start_response, the status remains unchanged from '200 OK'.

I got an inspection of the mp_request object being used by the handler, right after start_response is called. Note that status_line is changed but status isn't. Poking around in requestobject.c, I noticed only status_line is updated, I wonder if this has anything to do with it?

I was able to fix this for myself by hacking the WSGI handler to manually adjust req.status property:

# in wsgi.py, line 67...

## Run the app

response = None
try:
    response = app(env, req.wsgi_start_response)
    req.status = int(req.status_line.split(' ', 1)[0])        # added this
    [req.write(token) for token in response]

Version info: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1e-fips mod_python/3.5.0- Python/2.7.7

Take a look at this and see if you can replicate it. Maybe it's just a weird quirk of the somewhat-legacy configuration of the university server I'm on.

@grisha grisha closed this as completed Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants