edisona / dpkt

Automatically exported from code.google.com/p/dpkt
Other
1 stars 0 forks source link

[patch] Handle HTTP responses with empty reasonst #118

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

import dpkt

resp = ("HTTP/1.1 200 \r\n"
        "Content-Type: text/plain\r\n"
        "Connection: close\r\n"
        "\r\n"
        "Hello, world.\r\n")

print dpkt.http.Response(resp)

What is the expected output? What do you see instead?
This should work, but raises IndexError instead.  The version is '1.1', the 
status is '200' and the reason is ''.

What version of the product are you using? On what operating system?
dpkt 1.8

Please provide any additional information below.
I've attached a patch to fix this bug.  I used a regular expression to parse 
the status line, since the grammar for the status line is regular, but I 
noticed that the current codebase contains no use of regular expressions.  If 
you want a version that doesn't use them, let me know and I'll come up with 
something.

Original issue reported on code.google.com by george.m...@gmail.com on 18 Dec 2013 at 4:18

Attachments: