Skip to content

Commit

Permalink
WSGIHTTPException sets a default status code
Browse files Browse the repository at this point in the history
Make response.status be more strict about what you give it. i.e. if you
pass in a string yourself, it should have a valid integer code.
  • Loading branch information
digitalresistor committed Apr 14, 2015
1 parent 55ea77d commit 107b079
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/test_exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ def start_response(status, headers, exc_info=None):
assert_equal( excep(environ,start_response), [
b'<html>\n'
b' <head>\n'
b' <title>None None</title>\n'
b' <title>500 Internal Server Error</title>\n'
b' </head>\n'
b' <body>\n'
b' <h1>None None</h1>\n'
b' <h1>500 Internal Server Error</h1>\n'
b' <br /><br />\n'
b'\n'
b'\n\n'
Expand Down
4 changes: 2 additions & 2 deletions webob/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ class WSGIHTTPException(Response, HTTPException):
# title = 'OK'
# explanation = 'why this happens'
# body_template_obj = Template('response template')
code = None
title = None
code = 500
title = 'Internal Server Error'
explanation = ''
body_template_obj = Template('''\
${explanation}<br /><br />
Expand Down
3 changes: 3 additions & 0 deletions webob/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ def _status__set(self, value):
value += ' ' + status_reasons[int(value)]
except KeyError:
value += ' ' + status_generic_reasons[int(value) // 100]

# Attempt to get the status code itself, if this fails we should fail
status_code = int(value.split()[0])
self._status = value

status = property(_status__get, _status__set, doc=_status__get.__doc__)
Expand Down

0 comments on commit 107b079

Please sign in to comment.