Skip to content

Commit

Permalink
Use updated headers from server state (#1706)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Oct 19, 2022
1 parent 255dcde commit 001e7d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions uvicorn/protocols/http/h11_impl.py
Original file line number Diff line number Diff line change
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 @@ -250,7 +249,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
Original file line number Diff line number Diff line change
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 @@ -211,7 +210,7 @@ def handle_websocket_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 @@ -286,7 +285,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

0 comments on commit 001e7d7

Please sign in to comment.