Skip to content

Commit

Permalink
[Fixbug]: Load big packet error (#20)
Browse files Browse the repository at this point in the history
Reset packet_len if didn't find the delimiter
  • Loading branch information
Pterosaur authored May 26, 2019
1 parent 5d06be0 commit 49945a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions pywb/packetsloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def _load_packets_from_pkt_files(files):
else:
packet_len = buffer_.find('\0')
if packet_len == -1:
packet_len = 0
break
if packet_len >= 0:
if len(buffer_) >= packet_len:
Expand Down
8 changes: 8 additions & 0 deletions tests/data/big_packet.pkt

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions tests/test_pywb.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
counter["request"] += 1
def do_POST(self):
self.send_response(200)
counter["request"] += 1
with common.HTTPServerInstance(HTTPHandler):
expect_request_count = 3
main.execute(["-v", "4", "-n", str(expect_request_count),
"localhost:" + str(common._PORT)])
assert(counter["request"] == expect_request_count)

counter["request"] = 0
packet_file = os.path.join(os.path.dirname(
__file__), "data", "big_packet.pkt")
main.execute(["-v", "4", "-n", "1", "-F", packet_file,
"localhost:" + str(common._PORT)])
assert(counter["request"] == 1)


def test_send_packet_specified_timelimit():
with common.HTTPServerInstance():
Expand Down

0 comments on commit 49945a3

Please sign in to comment.