Always show server location in ASGI (#2522)

Co-authored-by: Adam Hopkins <adam@amhopkins.com>
Co-authored-by: Zhiwei Liang <zhi.wei.liang@outlook.com>
Co-authored-by: Néstor Pérez <25409753+prryplatypus@users.noreply.github.com>
This commit is contained in:
Adam Hopkins
2022-08-11 10:00:35 +03:00
parent f4c8252185
commit 3abe4f885e
4 changed files with 18 additions and 4 deletions

View File

@@ -546,3 +546,13 @@ async def test_signals_triggered(app):
assert response.status_code == 200
assert response.text == "test_signals_triggered"
assert signals_triggered == signals_expected
@pytest.mark.asyncio
async def test_asgi_serve_location(app):
@app.get("/")
def _request(request: Request):
return text(request.app.serve_location)
_, response = await app.asgi_client.get("/")
assert response.text == "http://<ASGI>"

View File

@@ -2,6 +2,7 @@ import json as stdjson
from collections import namedtuple
from pathlib import Path
from sys import version_info
import pytest
@@ -74,7 +75,10 @@ def test_full_message(client):
"""
)
response = client.recv()
assert len(response) == 151
# AltSvcCheck touchup removes the Alt-Svc header from the
# response in the Python 3.9+ in this case
assert len(response) == (151 if version_info < (3, 9) else 140)
assert b"200 OK" in response