Skip to content

Commit

Permalink
Merge branch 'main' of github.com:NZX/extra
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien committed Oct 2, 2024
2 parents 2afd3c1 + 59e15be commit 7f548f4
Show file tree
Hide file tree
Showing 6 changed files with 331 additions and 182 deletions.
17 changes: 2 additions & 15 deletions examples/client-gzip.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
import asyncio
from extra.client import HTTPClient
from extra.http.model import HTTPBodyBlob

import zlib


class GzipDecoder:
def __init__(self):
self.decompressor = zlib.decompressobj(wbits=zlib.MAX_WBITS | 32)
self.buffer = io.BytesIO()

def feed(self, chunk: bytes) -> bytes | None:
return self.decompressor.decompress(chunk)

def flush(self) -> bytes | None:
return self.decompressor.flush()
from extra.utils.codec import GZipDecoder


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

with open("/dev/stdout", "wb") as f:
async for atom in HTTPClient.Request(
Expand Down
6 changes: 3 additions & 3 deletions src/py/extra/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
HTTPBodyFile,
HTTPHeaders,
HTTPBody,
HTTPReaderBody,
HTTPBodyIO,
HTTPAtom,
HTTPProcessingStatus,
)
Expand Down Expand Up @@ -479,7 +479,7 @@ async def Request(
*,
port: int | None = None,
headers: dict[str, str] | None = None,
body: HTTPReaderBody | HTTPBodyBlob | None = None,
body: HTTPBodyIO | HTTPBodyBlob | None = None,
params: dict[str, str] | str | None = None,
ssl: bool = True,
verified: bool = True,
Expand Down Expand Up @@ -591,7 +591,7 @@ async def request(
*,
port: int | None = None,
headers: dict[str, str] | None = None,
body: HTTPReaderBody | HTTPBodyBlob | None = None,
body: HTTPBodyIO | HTTPBodyBlob | None = None,
params: dict[str, str] | str | None = None,
ssl: bool = True,
verified: bool = True,
Expand Down
Loading

0 comments on commit 7f548f4

Please sign in to comment.