Skip to content

Commit 31639ec

Browse files
committed
Bugfix don't double-access log if the response was sent
The access log after StreamClosed is meant for requests that are not responded to - usually due to an error that would otherwise go unnoticed without this log.
1 parent 155a1f6 commit 31639ec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/hypercorn/protocol/http_stream.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ async def handle(self, event: Event) -> None:
110110
await self.app_put({"type": "http.request", "body": b"", "more_body": False})
111111
elif isinstance(event, StreamClosed):
112112
self.closed = True
113-
await self.config.log.access(self.scope, None, time() - self.start_time)
113+
if self.state != ASGIHTTPState.CLOSED:
114+
await self.config.log.access(self.scope, None, time() - self.start_time)
114115
if self.app_put is not None:
115116
await self.app_put({"type": "http.disconnect"})
116117

0 commit comments

Comments
 (0)