This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
621 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ jobs: | |
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
os: | ||
- ubuntu-latest | ||
- windows-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,37 @@ | ||
__version__ = "0.0.0" | ||
|
||
import importlib | ||
import zlib as zlib_original | ||
|
||
import aiohttp | ||
from zlib_ng import zlib_ng as zlib_ng | ||
|
||
TARGETS = ( | ||
"compression_utils", | ||
"http_writer", | ||
"http_websocket", | ||
"http_writer", | ||
"multipart", | ||
"web_response", | ||
) | ||
|
||
|
||
def enable_zlib_ng() -> None: | ||
"""Enable zlib-ng.""" | ||
for location in TARGETS: | ||
try: | ||
importlib.import_module(f"aiohttp.{location}") | ||
except ImportError: | ||
continue | ||
if module := getattr(aiohttp, location, None): | ||
module.zlib = zlib_ng | ||
|
||
|
||
def disable_zlib_ng() -> None: | ||
"""Disable zlib-ng and restore the original zlib.""" | ||
for location in TARGETS: | ||
if module := getattr(aiohttp, location, None): | ||
module.zlib = zlib_original | ||
|
||
|
||
enable_zlib_ng() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import zlib as zlib_original | ||
|
||
import aiohttp.http_websocket | ||
from zlib_ng import zlib_ng as zlib_ng | ||
|
||
from aiohttp_zlib_ng import disable_zlib_ng, enable_zlib_ng | ||
|
||
|
||
def test_enable_disable(): | ||
"""Test enable/disable.""" | ||
assert aiohttp.http_websocket.zlib is zlib_ng | ||
disable_zlib_ng() | ||
assert aiohttp.http_websocket.zlib is zlib_original | ||
enable_zlib_ng() | ||
assert aiohttp.http_websocket.zlib is zlib_ng |
This file was deleted.
Oops, something went wrong.