Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use updated headers from server state #1706

Merged
merged 1 commit into from Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions uvicorn/protocols/http/h11_impl.py
Expand Up @@ -92,7 +92,6 @@ def __init__(
self.server_state = server_state
self.connections = server_state.connections
self.tasks = server_state.tasks
self.default_headers = server_state.default_headers

# Per-connection state
self.transport: asyncio.Transport = None # type: ignore[assignment]
Expand Down Expand Up @@ -230,7 +229,7 @@ def handle_events(self) -> None:
logger=self.logger,
access_logger=self.access_logger,
access_log=self.access_log,
default_headers=self.default_headers,
default_headers=self.server_state.default_headers,
message_event=asyncio.Event(),
on_response=self.on_response_complete,
)
Expand Down
5 changes: 2 additions & 3 deletions uvicorn/protocols/http/httptools_impl.py
Expand Up @@ -90,7 +90,6 @@ def __init__(
self.server_state = server_state
self.connections = server_state.connections
self.tasks = server_state.tasks
self.default_headers = server_state.default_headers

# Per-connection state
self.transport: asyncio.Transport = None # type: ignore[assignment]
Expand Down Expand Up @@ -199,7 +198,7 @@ def handle_upgrade(self) -> None:
def send_400_response(self, msg: str) -> None:

content = [STATUS_LINE[400]]
for name, value in self.default_headers:
for name, value in self.server_state.default_headers:
content.extend([name, b": ", value, b"\r\n"])
content.extend(
[
Expand Down Expand Up @@ -274,7 +273,7 @@ def on_headers_complete(self) -> None:
logger=self.logger,
access_logger=self.access_logger,
access_log=self.access_log,
default_headers=self.default_headers,
default_headers=self.server_state.default_headers,
message_event=asyncio.Event(),
expect_100_continue=self.expect_100_continue,
keep_alive=http_version != "1.0",
Expand Down