Skip to content

Commit 7f548f4

Browse files
committed
Merge branch 'main' of github.com:NZX/extra
2 parents 2afd3c1 + 59e15be commit 7f548f4

File tree

6 files changed

+331
-182
lines changed

6 files changed

+331
-182
lines changed

examples/client-gzip.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
11
import asyncio
22
from extra.client import HTTPClient
33
from extra.http.model import HTTPBodyBlob
4-
5-
import zlib
6-
7-
8-
class GzipDecoder:
9-
def __init__(self):
10-
self.decompressor = zlib.decompressobj(wbits=zlib.MAX_WBITS | 32)
11-
self.buffer = io.BytesIO()
12-
13-
def feed(self, chunk: bytes) -> bytes | None:
14-
return self.decompressor.decompress(chunk)
15-
16-
def flush(self) -> bytes | None:
17-
return self.decompressor.flush()
4+
from extra.utils.codec import GZipDecoder
185

196

207
# NOTE: Start "examples/sse.py"
218
async def main(path: str, host: str = "127.0.0.1", port: int = 443, ssl: bool = True):
22-
transform = GzipDecoder()
9+
transform = GZipDecoder()
2310

2411
with open("/dev/stdout", "wb") as f:
2512
async for atom in HTTPClient.Request(

src/py/extra/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
HTTPBodyFile,
1717
HTTPHeaders,
1818
HTTPBody,
19-
HTTPReaderBody,
19+
HTTPBodyIO,
2020
HTTPAtom,
2121
HTTPProcessingStatus,
2222
)
@@ -479,7 +479,7 @@ async def Request(
479479
*,
480480
port: int | None = None,
481481
headers: dict[str, str] | None = None,
482-
body: HTTPReaderBody | HTTPBodyBlob | None = None,
482+
body: HTTPBodyIO | HTTPBodyBlob | None = None,
483483
params: dict[str, str] | str | None = None,
484484
ssl: bool = True,
485485
verified: bool = True,
@@ -591,7 +591,7 @@ async def request(
591591
*,
592592
port: int | None = None,
593593
headers: dict[str, str] | None = None,
594-
body: HTTPReaderBody | HTTPBodyBlob | None = None,
594+
body: HTTPBodyIO | HTTPBodyBlob | None = None,
595595
params: dict[str, str] | str | None = None,
596596
ssl: bool = True,
597597
verified: bool = True,

0 commit comments

Comments
 (0)