Skip to content

Incorrect detection of status_code in Request #121

@igrishaev

Description

@igrishaev

When the Response was created from stream, the _status_code__get() method cannot detect status code properly, becourse it tries to sptlit start line and convert first element to int (HTTP/1.1 in my case).

resp = """HTTP/1.1 200 OK
Cache-Control: private, no-store,No-Store
Content-Length: 1024
Content-Type: application/octet-stream
ETag: ""
Server: Microsoft-IIS/7.5
content-disposition: attachment; filename=1kb.txt
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Thu, 19 Sep 2013 13:57:07 GMT

Some data...
"""

s = StringIO()
s.write(resp)
s.seek(0)

r = Response.from_file(s)
print r.status_code

Traceback (most recent call last):
  File "<string>", line 254, in run_nodebug
  File "...", line 45, in <module>
    print r.status_code
  File "C:\Python27\lib\site-packages\webob\response.py", line 272, in _status_code__get
    return int(self._status.split()[0])
ValueError: invalid literal for int() with base 10: 'HTTP/1.1'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions