Skip to content

webob.Response.from_file parsing failure #250

Description

@rtilder

webob.Request's from_file method seems have to an incorrect call to str.split()

    import io, webob
    s = "HTTP/1.0 200 Ok\nConnection: close\n\n"
    webob.Request.from_file(io.BytesIO(s))  # success
    s = "HTTP/1.0 404 Not Found\nConnection: close\n\n"
    webob.Request.from_file(io.BytesIO(s))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Users/rtilder/sandbox/horked_from_file/lib/python2.7/site-packages/webob/response.py", line 179, in from_file
        (http_ver, status_num, status_text) = status.split()
    ValueError: too many values to unpack

Relevant code is here. The existing code works just fine on a 200 response but not on the faux 404

(http_ver, status_num, status_text) = status.split()

I suspect that this is inadvertent and that the following was probably intended.

(http_ver, status_num, status_text) = status.split(None, 2)

I was a little surprised I ran into this until I realized that parsing HTTP responses is probably not a terribly common use case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions