Permalink
Browse files

Allowing storages to give bad request if something goes wrong when re…

…solving the name. This is really important so tornado does not have hanging connections.
  • Loading branch information...
1 parent 2d1c2d3 commit 5c06f512127d73d815107ab8fdc2c7b0dc5548ef @heynemann heynemann committed Aug 3, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 thumbor/handlers/upload.py
@@ -12,6 +12,10 @@
from thumbor.handlers import ContextHandler
+class BadRequestError(ValueError):
+ pass
+
+
class UploadHandler(ContextHandler):
def write_file(self, filename, body, overwrite):
@@ -45,6 +49,9 @@ def save_and_render(self, overwrite=False):
except RuntimeError:
self.set_status(409)
path = 'File already exists.'
+ except BadRequestError:
+ self.set_status(400)
+ path = 'Invalid request'
self.write(path)
def post(self):

0 comments on commit 5c06f51

Please sign in to comment.