Skip to content

Commit

Permalink
Handle request body read timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Apr 3, 2016
1 parent 0e9b3be commit 17df28c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cockatiel/handlers.py
Expand Up @@ -60,6 +60,11 @@ def put_file(request: web.Request):

with tempfile.SpooledTemporaryFile(max_size=1024 * 1024) as tmpfile:
for chunk in request_chunks(request):
if isinstance(chunk, asyncio.Future):
try:
chunk = yield from asyncio.wait_for(chunk, timeout=60)
except asyncio.TimeoutError:
raise web.HTTPRequestTimeout()
checksum.update(chunk)
tmpfile.write(chunk)

Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Expand Up @@ -44,6 +44,7 @@ API methods
:status 302: if the file already existed on this server previously
:status 400: if you specified a SHA1 hash and it does not match the
hash calculated on the server
:status 408: if data is coming in to slow
:status 500: on any internal errors

.. http:delete:: /(filename)
Expand Down

0 comments on commit 17df28c

Please sign in to comment.