Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dpkt/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Message(dpkt.Packet):

def __init__(self, *args, **kwargs):
if args:
self.unpack(args[0])
self.unpack(args[0], **kwargs)
else:
self.headers = OrderedDict()
self.body = b''
Expand Down Expand Up @@ -175,7 +175,7 @@ class Request(Message):
))
__proto = 'HTTP'

def unpack(self, buf):
def unpack(self, buf, **kwargs):
f = BytesIO(buf)
line = f.readline().decode("ascii", "ignore")
l_ = line.strip().split()
Expand Down Expand Up @@ -229,7 +229,7 @@ class Response(Message):
}
__proto = 'HTTP'

def unpack(self, buf):
def unpack(self, buf, head_response=False, **kwargs):
f = BytesIO(buf)
line = f.readline()
l_ = line.strip().decode("ascii", "ignore").split(None, 2)
Expand All @@ -249,6 +249,8 @@ def unpack(self, buf):
# MUST NOT include a message-body. All other responses do include a
# message-body, although it MAY be of zero length.
is_body_allowed = int(self.status) >= 200 and 204 != int(self.status) != 304
if head_response:
is_body_allowed = False
Message.unpack(self, f.read(), is_body_allowed)

def __str__(self):
Expand Down