-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
curl is not agree wit return in chunk mode #1722
Comments
Sanic's default request maximum size is 100 MB. Set Security precaution: a remote attacker could consume all your RAM by sending a very large request to your non-streaming endpoints. IMO the main limit ought not to apply to streaming handlers, where the handler itself may at any phase stop the transfer, and where the whole request doesn't need to get buffered in RAM. But this requires some structural changes in Sanic because now such requests are rejected as soon as a header states content-size larger than the limit. Routing should be done as soon as the path is received, so that the limit can be ignored for streaming handlers. |
Thank you very much. |
No, it is not possible to configure it per-request in any meaningful way. Even if you could hack chunked-encoding to work around the limit, any upload which provides body size in request header (content-size instead of chunked encoding) would still get rejected before routing, middleware or your handler are called. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions. |
This is to be sorted out in #1791 |
This is now sorted out in #1791 where streaming handlers may change the limit before reading the body: @app.post("/bigdata", stream=True)
async def bigdata(request):
request.stream.request_max_size = 1_000_000_000
async for data in request.stream:
# do something Changing the limit before |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions. |
for uploading large file > 200 MB I write:
@app.post('/data', stream=True)
async def handler(_request):
async def streaming(_response):
total_size = 0
while True:
body = await _request.stream.read()
if body is None:
break
total_size += len(body)
print("body " + str(len(body)) + "/" + str(total_size))
return response.stream(streaming)
curl -F 'file=@Totally_Spies.mp4' -H 'transfer-encoding:chunked' 127.0.0.1:15080/data -X POST -O
curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding
The text was updated successfully, but these errors were encountered: