Repos / mcross / 2e771dae83
commit 2e771dae833f99dbe02e46a4955a82b59e8562ed
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Sat May 16 16:36:28 2020 +0700
fix partial response bug
hey I just touched tcp stuff like 2 days ago don't judge me
diff --git a/pyproject.toml b/pyproject.toml
index 2d80b51..9bd58a8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mcross"
-version = "0.4.2"
+version = "0.4.3"
description = "Do you remember www?"
authors = ["nhanb <hi@imnhan.com>"]
license = "MIT"
diff --git a/src/mcross/transport.py b/src/mcross/transport.py
index 0a74c05..8d1ff3f 100644
--- a/src/mcross/transport.py
+++ b/src/mcross/transport.py
@@ -118,7 +118,13 @@ def raw_get(url: GeminiUrl):
resp = Response(status=status, meta=meta, url=url)
if status.startswith("2"):
- resp.body = ssock.recv(MAX_RESP_BODY_BYTES)
+ body = b""
+ msg = ssock.recv(4096)
+ body += msg
+ while msg and len(body) <= MAX_RESP_BODY_BYTES:
+ msg = ssock.recv(4096)
+ body += msg
+ resp.body = body
return resp