Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
python-uvicorn
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Debian Python Team
packages
python-uvicorn
Commits
55718a39
Commit
55718a39
authored
1 year ago
by
Michael Fladischer
Browse files
Options
Downloads
Patches
Plain Diff
Add patch for compatibility with httpx 0.27.0 (Closes: #1066793).
parent
edf846ea
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
debian/patches/0005-Compatibility-with-httpx-0.27.0.patch
+122
-0
122 additions, 0 deletions
debian/patches/0005-Compatibility-with-httpx-0.27.0.patch
debian/patches/series
+1
-0
1 addition, 0 deletions
debian/patches/series
with
123 additions
and
0 deletions
debian/patches/0005-Compatibility-with-httpx-0.27.0.patch
0 → 100644
+
122
−
0
View file @
55718a39
From: Michael Fladischer <fladi@debian.org>
Date: Sat, 16 Mar 2024 21:48:56 +0000
Subject: Compatibility with httpx 0.27.0.
---
tests/middleware/test_message_logger.py | 6 ++++--
tests/middleware/test_proxy_headers.py | 9 ++++++---
tests/middleware/test_wsgi.py | 15 ++++++++++-----
3 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/tests/middleware/test_message_logger.py b/tests/middleware/test_message_logger.py
index 3f5c3af..165686b 100644
--- a/tests/middleware/test_message_logger.py
+++ b/tests/middleware/test_message_logger.py
@@ -18,7 +18,8 @@
async def test_message_logger(caplog):
caplog.set_level(TRACE_LOG_LEVEL)
app = MessageLoggerMiddleware(app)
- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
response = await client.get("/")
assert response.status_code == 200
messages = [record.msg % record.args for record in caplog.records]
@@ -38,7 +39,8 @@
async def test_message_logger_exc(caplog):
caplog.set_level(TRACE_LOG_LEVEL, logger="uvicorn.asgi")
caplog.set_level(TRACE_LOG_LEVEL)
app = MessageLoggerMiddleware(app)
- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
with pytest.raises(RuntimeError):
await client.get("/")
messages = [record.msg % record.args for record in caplog.records]
diff --git a/tests/middleware/test_proxy_headers.py b/tests/middleware/test_proxy_headers.py
index 6d7fc8c..a36f882 100644
--- a/tests/middleware/test_proxy_headers.py
+++ b/tests/middleware/test_proxy_headers.py
@@ -49,7 +49,8 @@
async def app(
)
async def test_proxy_headers_trusted_hosts(trusted_hosts: list[str] | str, response_text: str) -> None:
app_with_middleware = ProxyHeadersMiddleware(app, trusted_hosts=trusted_hosts)
- async with httpx.AsyncClient(app=app_with_middleware, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app_with_middleware)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
headers = {"X-Forwarded-Proto": "https", "X-Forwarded-For": "1.2.3.4"}
response = await client.get("/", headers=headers)
@@ -79,7 +80,8 @@
async def test_proxy_headers_trusted_hosts(trusted_hosts: list[str] | str, respo
)
async def test_proxy_headers_multiple_proxies(trusted_hosts: list[str] | str, response_text: str) -> None:
app_with_middleware = ProxyHeadersMiddleware(app, trusted_hosts=trusted_hosts)
- async with httpx.AsyncClient(app=app_with_middleware, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app_with_middleware)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
headers = {
"X-Forwarded-Proto": "https",
"X-Forwarded-For": "1.2.3.4, 10.0.2.1, 192.168.0.2",
@@ -93,7 +95,8 @@
async def test_proxy_headers_multiple_proxies(trusted_hosts: list[str] | str, re
@pytest.mark.anyio
async def test_proxy_headers_invalid_x_forwarded_for() -> None:
app_with_middleware = ProxyHeadersMiddleware(app, trusted_hosts="*")
- async with httpx.AsyncClient(app=app_with_middleware, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app_with_middleware)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
headers = httpx.Headers(
{
"X-Forwarded-Proto": "https",
diff --git a/tests/middleware/test_wsgi.py b/tests/middleware/test_wsgi.py
index adc8e24..b028e6f 100644
--- a/tests/middleware/test_wsgi.py
+++ b/tests/middleware/test_wsgi.py
@@ -60,7 +60,8 @@
def wsgi_middleware(request: pytest.FixtureRequest) -> Callable:
@pytest.mark.anyio
async def test_wsgi_get(wsgi_middleware: Callable) -> None:
app = wsgi_middleware(hello_world)
- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
response = await client.get("/")
assert response.status_code == 200
assert response.text == "Hello World!\n"
@@ -69,7 +70,8 @@
async def test_wsgi_get(wsgi_middleware: Callable) -> None:
@pytest.mark.anyio
async def test_wsgi_post(wsgi_middleware: Callable) -> None:
app = wsgi_middleware(echo_body)
- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
response = await client.post("/", json={"example": 123})
assert response.status_code == 200
assert response.text == '{"example": 123}'
@@ -82,7 +84,8 @@
async def test_wsgi_put_more_body(wsgi_middleware: Callable) -> None:
yield b"123456789abcdef\n" * 64
app = wsgi_middleware(echo_body)
- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
response = await client.put("/", content=generate_body())
assert response.status_code == 200
assert response.text == "123456789abcdef\n" * 64 * 1024
@@ -93,7 +96,8 @@
async def test_wsgi_exception(wsgi_middleware: Callable) -> None:
# Note that we're testing the WSGI app directly here.
# The HTTP protocol implementations would catch this error and return 500.
app = wsgi_middleware(raise_exception)
- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
with pytest.raises(RuntimeError):
await client.get("/")
@@ -103,7 +107,8 @@
async def test_wsgi_exc_info(wsgi_middleware: Callable) -> None:
# Note that we're testing the WSGI app directly here.
# The HTTP protocol implementations would catch this error and return 500.
app = wsgi_middleware(return_exc_info)
- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+ transport = httpx.ASGITransport(app=app)
+ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
with pytest.raises(RuntimeError):
response = await client.get("/")
This diff is collapsed.
Click to expand it.
debian/patches/series
+
1
−
0
View file @
55718a39
...
...
@@ -2,3 +2,4 @@
0002-Remove-image-badges-to-prevent-privacy-breaches.patch
0003-Fix-asyncio-warnings.patch
0004-Use-local-image-resource-to-prevent-privacy-breach.patch
0005-Compatibility-with-httpx-0.27.0.patch
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment