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

304 response should return no content-type header by default #112

Closed
rapto opened this issue Jul 18, 2013 · 4 comments
Closed

304 response should return no content-type header by default #112

rapto opened this issue Jul 18, 2013 · 4 comments

Comments

@rapto
Copy link

rapto commented Jul 18, 2013

In our application, some ajax calls return xml. The second time the same request is issued, we detect the etag is the same, so we return HTTPNotModified().

The problem is that a 'content-type: text/html' is added, making the response unusable as XML (at least in Chrome, which leaves responseXML empty for a non text/xml response). This happens even if a content_type is added in the constructor: HTTPNotModified(content_type='text/xml').

I have not studied the corner cases in the standard, but I feel that HTTPNotModified should return no content-type or the one explicitly provided, at least.

I'll try to submit a patch as soon as I can.

@digitalresistor
Copy link
Member

Do you have an example minimal test case that showcases the issue? I am trying to reproduce this, but by default HTTPNotModified() does not set any content_type, nor any headers for that matter other than the 304 status code.

If this is no longer an issue please close this bug report.

@digitalresistor
Copy link
Member

Test code used:

def test_HTTPNotModified_headers():
    _status = None
    _headers = None

    def start_response(status, headers, exc_info=None):
        print(status)
        print(headers)

    environ = {
       'wsgi.url_scheme': 'HTTP',
       'SERVER_NAME': 'localhost',
       'SERVER_PORT': '80',
       'REQUEST_METHOD': 'GET',
       'HTTP_ACCEPT': 'text/html'
    }

    excep = HTTPNotModified()
    resp = excep(environ, start_response)
    print(resp)

@digitalresistor
Copy link
Member

Closing issue due to no followup. If this is still an issue please re-open.

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

3 participants