question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bottle+cherrypy gives ""TypeError: WSGI response header key 'Content-Length' is not a byte string"

See original GitHub issue

I am not sure if this is a bottle or a cherrypy issue, but anyway

I’m using the following configuration:

Arch Linux with 2.6.32-lts kernel hardware: i686 Intel® Atom™ CPU N270 @ 1.60GHz python 3.2 cherrypy-svn 2567-1 bottle 0.9.5

Both a Bottle and a Cherrypy ‘hello world’ run fine. But when I try to run Bottle with Cherrypy like this:


from bottle import route, run

@route(‘/’) def hello(): return ‘hello world’

run(server=‘cherrypy’,host=‘192.168.1.5’, port=8080)


I get this error message:


Traceback (most recent call last): File “/usr/lib/python3.2/site-packages/bottle.py”, line 743, in wsgi start_response(status, response.headerlist) File “/usr/lib/python3.2/site-packages/cherrypy/wsgiserver/wsgiserver3.py”, line 1846, in start_response raise TypeError(“WSGI response header key %r is not a byte string.” % k) TypeError: WSGI response header key ‘Content-Length’ is not a byte string.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/usr/lib/python3.2/site-packages/cherrypy/wsgiserver/wsgiserver3.py”, line 1034, in communicate req.respond() File “/usr/lib/python3.2/site-packages/cherrypy/wsgiserver/wsgiserver3.py”, line 830, in respond self.server.gateway(self).respond() File “/usr/lib/python3.2/site-packages/cherrypy/wsgiserver/wsgiserver3.py”, line 1808, in respond response = self.req.server.wsgi_app(self.env, self.start_response) File “/usr/lib/python3.2/site-packages/bottle.py”, line 759, in call return self.wsgi(environ, start_response) File “/usr/lib/python3.2/site-packages/bottle.py”, line 755, in wsgi start_response(‘500 INTERNAL SERVER ERROR’, [(‘Content-Type’, ‘text/html’)]) File “/usr/lib/python3.2/site-packages/cherrypy/wsgiserver/wsgiserver3.py”, line 1830, in start_response raise AssertionError("WSGI start_response called a second " AssertionError: WSGI start_response called a second time with no exc_info. `

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
simevocommented, Jan 4, 2017

for future reference the cherrypy ticket is now here: https://github.com/cherrypy/cherrypy/issues/1087

0reactions
defnullcommented, Dec 13, 2011

Thanks for the feedback. Fixed upstream -> closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does WSGI override `Content-Length` header? - Stack Overflow
There is no such configuration setting. You have to override or modify wsgiref/handlers.py , like this: from wsgiref.simple_server import ...
Read more >
falcon.response — Falcon 3.1.1 documentation
HTTPStatus`, an HTTP status line string or byte string (e.g., ... (int): Length of the stream, used for the Content-Length header in the...
Read more >
https://strike.scec.org/csep/cherrypy/cherrypy/wsg...
This function raises ValueError when the read bytes violate the HTTP spec. ... str): raise TypeError("WSGI response header key %r is not of...
Read more >
Response — WebOb 1.8.7 documentation - The Pylons Project
Should conform to the WSGI requirements and should provide bytes. ... If no content_type is provided, and there is no headerlist , the...
Read more >
sequence of byte string values expected, value of type str found
output = b'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found