bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.45k stars 1.46k forks source link

Redirect with WSGIproxy results in "no space following status code" #946

Open datacticapertti opened 7 years ago

datacticapertti commented 7 years ago

I was setting up a simple proxy with bottle and wsgiproxy, the proxy is in the attached file. When the proxied server replies with a 302 redirect, I get the following error.

Critical error while processing request: /proxy/midpoint
Error:

ValueError('no space following status code',)

Traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 960, in wsgi
    start_response(response._status_line, response.headerlist)
ValueError: no space following status code

Chasing this I discovered that indeed response._status_line is "302" with no trailing space in that line. I'm not sure if it is bottle or wsgiproxy that forgets to add the space there, but anyway it would be good if bottle tried to make sure the status line is formatted correctly

Wsgiproxy is the one you get by running "pip install wsgiproxy".

authproxy.txt

defnull commented 7 years ago

Code to reproduce (I think): bottle.response.status="302 " Notice that the status string contains a space (and is therefor recognize as a valid status line), but nothing after the space. Bottle strips the last space internally, resulting in an invalid status line.

This is an unusual use of response.statusand probably a bug in the application, but it's easy to detect and bottle should throw a ValueError in this case.