Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix data type

  • Loading branch information...
commit b2e02a85fce69bf59a81541fc94d42b12d902eb5 1 parent b2f8f5a
@benoitc authored
Showing with 9 additions and 7 deletions.
  1. +7 −5 http_parser/http.py
  2. +2 −2 http_parser/reader.py
View
12 http_parser/http.py
@@ -11,7 +11,7 @@
from http_parser.pyparser import HttpParser
from http_parser.reader import HttpBodyReader
-from http_parser.util import status_reasons
+from http_parser.util import status_reasons, bytes_to_str
HTTP_BOTH = 2
HTTP_RESPONSE = 1
@@ -66,14 +66,16 @@ def _wait_status_line(self, cond):
if self.parser.is_headers_complete():
return True
+ data = []
if not cond():
while True:
try:
- next(self)
+ d = next(self)
+ data.append(d)
except StopIteration:
if self.parser.is_headers_complete():
return True
- raise BadStatusLine(data)
+ raise BadStatusLine(b"".join(data))
if cond():
return True
return True
@@ -196,8 +198,8 @@ def __next__(self):
# parse data
nparsed = self.parser.execute(to_parse, recved)
if nparsed != recved and not self.parser.is_message_complete():
- raise ParserError("nparsed != recved (%s != %s)" % (nparsed,
- recved))
+ raise ParserError("nparsed != recved (%s != %s) [%s]" % (nparsed,
+ recved, bytes_to_str(to_parse)))
if recved == 0:
raise StopIteration
View
4 http_parser/reader.py
@@ -73,8 +73,8 @@ def readinto(self, b):
if not self.http_stream.parser.is_partial_body():
self.eof = True
- b = bytes('')
- return len(b)
+ b = b''
+ return len(b'')
return self.http_stream.parser.recv_body_into(b)
Please sign in to comment.
Something went wrong with that request. Please try again.