without-http 0.0.8__tar.gz → 0.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: without-http
3
- Version: 0.0.8
3
+ Version: 0.0.10
4
4
  Summary: A sans-IO-backed ASGI server and HTTP client for without: h11/h2/wsproto over asyncio sockets.
5
5
  Author: Josh Karpel
6
6
  Author-email: Josh Karpel <josh.karpel@gmail.com>
@@ -16,9 +16,9 @@ Classifier: Topic :: Internet :: WWW/HTTP
16
16
  Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
17
17
  Classifier: Topic :: Software Development :: Libraries
18
18
  Classifier: Typing :: Typed
19
- Requires-Dist: without-async==0.0.8
20
- Requires-Dist: without-streams==0.0.8
21
- Requires-Dist: without-asgi==0.0.8
19
+ Requires-Dist: without-async==0.0.10
20
+ Requires-Dist: without-streams==0.0.10
21
+ Requires-Dist: without-asgi==0.0.10
22
22
  Requires-Dist: h11>=0.16
23
23
  Requires-Dist: h2>=4.1
24
24
  Requires-Dist: wsproto>=1.2
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "without-http"
7
- version = "0.0.8"
7
+ version = "0.0.10"
8
8
  description = "A sans-IO-backed ASGI server and HTTP client for without: h11/h2/wsproto over asyncio sockets."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -23,9 +23,9 @@ classifiers = [
23
23
  "Typing :: Typed",
24
24
  ]
25
25
  dependencies = [
26
- "without-async==0.0.8",
27
- "without-streams==0.0.8",
28
- "without-asgi==0.0.8",
26
+ "without-async==0.0.10",
27
+ "without-streams==0.0.10",
28
+ "without-asgi==0.0.10",
29
29
  "h11>=0.16",
30
30
  "h2>=4.1",
31
31
  "wsproto>=1.2",
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "without-http"
7
- version = "0.0.8"
7
+ version = "0.0.10"
8
8
  description = "A sans-IO-backed ASGI server and HTTP client for without: h11/h2/wsproto over asyncio sockets."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -26,9 +26,9 @@ classifiers = [
26
26
  "Typing :: Typed",
27
27
  ]
28
28
  dependencies = [
29
- "without-async==0.0.8",
30
- "without-streams==0.0.8",
31
- "without-asgi==0.0.8",
29
+ "without-async==0.0.10",
30
+ "without-streams==0.0.10",
31
+ "without-asgi==0.0.10",
32
32
  "h11>=0.16",
33
33
  "h2>=4.1",
34
34
  "wsproto>=1.2",
@@ -22,6 +22,7 @@ from datetime import UTC
22
22
  from datetime import datetime
23
23
  from datetime import timedelta
24
24
  from email.utils import parsedate_to_datetime
25
+ from functools import partial
25
26
  from importlib import metadata
26
27
  from types import MappingProxyType
27
28
  from typing import NamedTuple
@@ -1695,7 +1696,13 @@ def compressing(coding: bytes, make_compressor: Callable[[], Compressor]) -> Cli
1695
1696
  return wrap(request=apply)
1696
1697
 
1697
1698
 
1698
- def gzip_compress(level: int = zlib.Z_DEFAULT_COMPRESSION) -> ClientMiddleware:
1699
+ def gzip_compress(
1700
+ level: int = zlib.Z_DEFAULT_COMPRESSION,
1701
+ *,
1702
+ wbits: int = GZIP_CONTAINER,
1703
+ mem_level: int = zlib.DEF_MEM_LEVEL,
1704
+ strategy: int = zlib.Z_DEFAULT_STRATEGY,
1705
+ ) -> ClientMiddleware:
1699
1706
  """
1700
1707
  Client middleware that gzips every request body sent through it.
1701
1708
 
@@ -1708,15 +1715,26 @@ def gzip_compress(level: int = zlib.Z_DEFAULT_COMPRESSION) -> ClientMiddleware:
1708
1715
 
1709
1716
  The body streams through an incremental compressor and the framing follows the
1710
1717
  rewrite (see `compressing` for both, and for which requests pass through
1711
- untouched). `level` is zlib's compression level, defaulting to zlib's own
1712
- default. `zstd_compress` and `brotli_compress` are the same middleware over their
1713
- codings, and `compressing` is the shared mechanism for any coding beyond those;
1714
- the response-side counterpart to all of them is `decompress`.
1718
+ untouched). The arguments are `without_asgi.compression.gzip_compressor`'s, which
1719
+ are zlib's own. `zstd_compress` and `brotli_compress` are the same middleware over
1720
+ their codings, and `compressing` is the shared mechanism for any coding beyond
1721
+ those; the response-side counterpart to all of them is `decompress`.
1722
+
1723
+ Each of the three builds one compressor when called and discards it, so an
1724
+ argument the codec refuses raises here, at assembly, rather than on the first
1725
+ request that would have sent a body.
1715
1726
  """
1716
- return compressing(b"gzip", lambda: gzip_compressor(level))
1727
+ make_compressor = partial(gzip_compressor, level, wbits=wbits, mem_level=mem_level, strategy=strategy)
1728
+ make_compressor()
1729
+ return compressing(b"gzip", make_compressor)
1717
1730
 
1718
1731
 
1719
- def zstd_compress(level: int | None = None) -> ClientMiddleware:
1732
+ def zstd_compress(
1733
+ level: int | None = None,
1734
+ *,
1735
+ options: Mapping[int, int] | None = None,
1736
+ zstd_dict: zstd.ZstdDict | tuple[zstd.ZstdDict, int] | None = None,
1737
+ ) -> ClientMiddleware:
1720
1738
  """
1721
1739
  Client middleware that zstd-compresses every request body sent through it.
1722
1740
 
@@ -1725,12 +1743,23 @@ def zstd_compress(level: int | None = None) -> ClientMiddleware:
1725
1743
  differs. gzip is the coding everything decodes; reach for zstd where the upstream
1726
1744
  is known to decode it.
1727
1745
 
1728
- `level` is zstd's compression level, defaulting to the library's own default.
1746
+ The arguments are `without_asgi.compression.zstd_compressor`'s, which are the
1747
+ stdlib's `zstd.ZstdCompressor`'s own; a configuration whose window HTTP forbids
1748
+ raises `ValueError` here. A request is where `zstd_dict` fits, for an upstream
1749
+ known to hold the same dictionary.
1729
1750
  """
1730
- return compressing(b"zstd", lambda: zstd_compressor(level))
1751
+ make_compressor = partial(zstd_compressor, level, options=options, zstd_dict=zstd_dict)
1752
+ make_compressor()
1753
+ return compressing(b"zstd", make_compressor)
1731
1754
 
1732
1755
 
1733
- def brotli_compress(quality: int = 11) -> ClientMiddleware:
1756
+ def brotli_compress(
1757
+ quality: int = 11,
1758
+ *,
1759
+ mode: int = brotli.MODE_GENERIC,
1760
+ lgwin: int = 22,
1761
+ lgblock: int = 0,
1762
+ ) -> ClientMiddleware:
1734
1763
  """
1735
1764
  Client middleware that brotli-compresses every request body sent through it.
1736
1765
 
@@ -1740,9 +1769,12 @@ def brotli_compress(quality: int = 11) -> ClientMiddleware:
1740
1769
  defaulting to the bindings' own default of 11, the maximum, because a client
1741
1770
  compressing an upload it holds whole is the case that ratio is worth paying for.
1742
1771
  The server-side `compress` table defaults lower, since it encodes per response;
1743
- see `without_asgi.compression.brotli_compressor`, the shared codec behind both.
1772
+ see `without_asgi.compression.brotli_compressor`, the shared codec behind both,
1773
+ whose other arguments are the bindings' own.
1744
1774
  """
1745
- return compressing(b"br", lambda: brotli_compressor(quality))
1775
+ make_compressor = partial(brotli_compressor, quality, mode=mode, lgwin=lgwin, lgblock=lgblock)
1776
+ make_compressor()
1777
+ return compressing(b"br", make_compressor)
1746
1778
 
1747
1779
 
1748
1780
  class Decompressor(Protocol):
File without changes