Commit 0e632cbd authored by Michael Hanselmann's avatar Michael Hanselmann

http: Add wrapper for mimetools.Message

A newly added piece of code will also have to parse headers, so having
this wrapper saves us from copying this part of code.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 7a70541e
......@@ -323,6 +323,15 @@ class HttpVersionNotSupported(HttpException):
code = 505
def ParseHeaders(buf):
"""Parses HTTP headers.
@note: This is just a trivial wrapper around C{mimetools.Message}
"""
return mimetools.Message(buf, 0)
def SocketOperation(sock, op, arg1, timeout):
"""Wrapper around socket functions.
......@@ -998,7 +1007,7 @@ class HttpMessageReader(object):
"""
# Parse headers
self.header_buffer.seek(0, 0)
self.msg.headers = mimetools.Message(self.header_buffer, 0)
self.msg.headers = ParseHeaders(self.header_buffer, 0)
self.peer_will_close = self._WillPeerCloseConnection()
......
......@@ -25,7 +25,6 @@
import logging
import re
import mimetools
import base64
import pycurl
from cStringIO import StringIO
......@@ -172,7 +171,7 @@ class FakeCurl:
else:
baseheaders = ""
headers = mimetools.Message(StringIO(baseheaders), 0)
headers = http.ParseHeaders(StringIO(baseheaders))
if request_body:
headers[http.HTTP_CONTENT_LENGTH] = str(len(request_body))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment