Skip to content

Commit

Permalink
Quick fix for kbandla#648
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisBush authored Dec 1, 2022
1 parent 97ea45b commit b114296
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit b114296

Please sign in to comment.