File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1010from botocore .credentials import Credentials
1111import hmac
1212from starlette .datastructures import Headers
13+ from starlette .requests import ClientDisconnect
1314from starlette .responses import Response
1415from starlette .status import (
1516 HTTP_400_BAD_REQUEST ,
@@ -246,7 +247,12 @@ async def s3_endpoint(path: str, request: Request):
246247 # request (SigV4 streaming HTTP PUT) into a single-payload request (Normal SigV4 HTTP PUT).
247248 # We could also implement chunked signing but it's not straightforward and likely unnecessary.
248249 # Note: Chunked uploads != multipart uploads.
249- body = await request .body ()
250+ try :
251+ body = await request .body ()
252+ except ClientDisconnect : # catch this to avoid throwing 500 errors
253+ raise HTTPException (
254+ 499 , "Client disconnected before request body was fully received"
255+ )
250256 headers = {
251257 "host" : f"{ user_bucket } .s3.{ region } .amazonaws.com" ,
252258 "x-amz-date" : timestamp ,
You can’t perform that action at this time.
0 commit comments