This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author flox
Recipients flox, pitrou, pje
Date 2013-05-30.10:33:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1369910008.93.0.397797975418.issue18099@psf.upfronthosting.co.za>
In-reply-to
Content
While testing wsgiref w.r.t RFC2616, I noticed that it sets the Content-Length to 0 when the application returns 304 Not Modified.

This is a violation of RFC 2616 section 10.3.5.

And the net effect is a weird bug with some browsers (tested with Chrome 27) where the resource is truncated on 304 Not Modified.
(the resource was a CSS file in that case)

This is loosely related to http://bugs.python.org/issue3839.


# How to reproduce:

def test_304():
    import time
    from email.utils import formatdate
    from wsgiref.simple_server import make_server

    def demo_app(environ, start_response):
        if 'HTTP_IF_MODIFIED_SINCE' in environ:
            start_response("304 Not Modified", [])
            return []
        headers = [('Content-Type', 'text/html; charset=utf-8'),
                   ('Last-Modified', formatdate(time.time(), usegmt=True))]
        start_response("200 OK", headers)
        return ["Hello World!"]

    httpd = make_server('127.0.0.1', 8000, demo_app)
    sa = httpd.socket.getsockname()
    print("Serving HTTP on %s port %s ..." % sa)
    httpd.serve_forever()

if __name__ == '__main__':
    test_304()
History
Date User Action Args
2013-05-30 10:33:29floxsetrecipients: + flox, pje, pitrou
2013-05-30 10:33:28floxsetmessageid: <1369910008.93.0.397797975418.issue18099@psf.upfronthosting.co.za>
2013-05-30 10:33:28floxlinkissue18099 messages
2013-05-30 10:33:28floxcreate