Issue #561 resolved

_cpwsgiserver.py should coerce response header values to strings

Anonymous created an issue

While using _cpwsgiserver.py with my pylons WSGI application I am getting an exception raised at http://www.cherrypy.org/browser/trunk/cherrypy/_cpwsgiserver.py#L326 stating "TypeError: cannot concatenate 'str' and 'int' objects" because my Content-Length response header is an int.

I looked in the WSGI PEP and couldn't find a requirement that header values be strings and I did a quick survey of several WSGI apps and they all seem to use an int for the Content-Length header; so I think the response header values should be automatically coerced to strings in _cpwsgiserver.

I've only been using _cpwsgiserver for a total of 30 minutes so hopefully I'm not missing something obvious.

Thanks,

Wes Augur wes@oxona.com

Reported by wes@oxona.com

Comments (4)

  1. Robert Brewer

    Although the PEP is arguably vague on this point, wsgiref and paste.lint are not; for example:

    assert type(val) is StringType,"Header values must be strings"
    

    It would be in everyone's best interest for you to fix the application(s). However, we should probably decide this on web-sig, so I'm going to keep this open for now.

  2. Log in to comment