From 4572113b53c2d4487f0c0239661085c39509fbc0 Mon Sep 17 00:00:00 2001 From: KevinL10 Date: Sat, 26 Aug 2023 15:39:43 -0700 Subject: [PATCH] Fix bug with requesting chunked data --- browser/main.py | 3 +-- browser/request.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/browser/main.py b/browser/main.py index af9913e..072a2aa 100644 --- a/browser/main.py +++ b/browser/main.py @@ -8,8 +8,7 @@ if len(sys.argv) == 2: browser.load(sys.argv[1]) else: - browser.load("file:///home/vever/cs/browser/browser/tests/index.html") - # browser.load("https://browser.engineering/layout.html") + browser.load("https://browser.engineering/styles.html") # browser.load("https://www.w3.org/Style/CSS/Test/CSS1/current/test5526c.htm") diff --git a/browser/request.py b/browser/request.py index 84c3ff6..da88daa 100644 --- a/browser/request.py +++ b/browser/request.py @@ -98,12 +98,12 @@ def request(url, num_redirects=0): pos = 0 while True: start = body.find(b"\r\n", pos) - length = int(body[pos:start].decode()) + length = int(body[pos:start].decode(), 16) if length == 0: break - end = body.find(b"\r\n", start + 2) + end = start + length + 2 new_body += body[start + 2 : end] pos = end + 2