diff --git a/netlib/http.py b/netlib/http.py index da43d0704..1f5f8901d 100644 --- a/netlib/http.py +++ b/netlib/http.py @@ -1,4 +1,5 @@ import string, urlparse +import odict class HttpError(Exception): def __init__(self, code, msg): @@ -54,7 +55,7 @@ def read_headers(fp): name = line[:i] value = line[i+1:].strip() ret.append([name, value]) - return ret + return odict.ODictCaseless(ret) def read_chunked(code, fp, limit): @@ -107,7 +108,7 @@ def has_chunked_encoding(headers): def read_http_body(code, rfile, headers, all, limit): """ Read an HTTP body: - + code: The HTTP error code to be used when raising HttpError rfile: A file descriptor to read from headers: An ODictCaseless object diff --git a/test/test_http.py b/test/test_http.py index bf525de58..3546fec6b 100644 --- a/test/test_http.py +++ b/test/test_http.py @@ -155,7 +155,7 @@ class TestReadHeaders: data = data.strip() s = cStringIO.StringIO(data) h = http.read_headers(s) - assert h == [["Header", "one"], ["Header2", "two"]] + assert h.lst == [["Header", "one"], ["Header2", "two"]] def test_read_multi(self): data = """ @@ -167,7 +167,7 @@ class TestReadHeaders: data = data.strip() s = cStringIO.StringIO(data) h = http.read_headers(s) - assert h == [["Header", "one"], ["Header", "two"]] + assert h.lst == [["Header", "one"], ["Header", "two"]] def test_read_continued(self): data = """ @@ -180,7 +180,7 @@ class TestReadHeaders: data = data.strip() s = cStringIO.StringIO(data) h = http.read_headers(s) - assert h == [["Header", "one\r\n two"], ["Header2", "three"]] + assert h.lst == [["Header", "one\r\n two"], ["Header2", "three"]] def test_parse_url():