Skip to content

Commit efc936c

Browse files
committed
fix the ratelimit middleware eating all headers
1 parent d56a9b0 commit efc936c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

mystbin/backend/utils/ratelimits.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,8 @@ async def _transform_and_log(self, request: Request, response: Response) -> Resp
162162
status_code=response.status_code,
163163
background=response.background,
164164
media_type=cast(str, response.media_type),
165+
headers=response.headers, # type: ignore
165166
)
166-
del response._headers["content-type"]
167-
del response._headers["content-length"]
168-
resp_._headers = response._headers
169167
body = b""
170168
async for chunk in response.body_iterator:
171169
if not isinstance(chunk, bytes):
@@ -257,7 +255,8 @@ async def middleware(self, request: Request, call_next: _CT) -> Response:
257255
}
258256
resp = await call_next(request)
259257
resp.headers.update(headers)
260-
return await self._transform_and_log(request, resp)
258+
resp = await self._transform_and_log(request, resp)
259+
return resp
261260

262261

263262
def parse_ratelimit(limit: str) -> tuple[int, int]:

0 commit comments

Comments
 (0)