[etwist] use more specific REQUEST_ENTITY_TOO_LARGE instead of BAD_REQUEST
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 08 Jul 2014 11:33:32 +0200
changeset 9919 e013c35067d7
parent 9918 228c3571e222
child 9929 16163ee1cdf9
[etwist] use more specific REQUEST_ENTITY_TOO_LARGE instead of BAD_REQUEST When a request body exceeds the configured limit, return 413 to the client instead of a generic 400.
etwist/server.py
--- a/etwist/server.py	Tue Jul 08 10:34:50 2014 +0200
+++ b/etwist/server.py	Tue Jul 08 11:33:32 2014 +0200
@@ -178,7 +178,7 @@
         path = self.channel._path.split('?', 1)[0].rstrip('/').rsplit('/', 1)[-1]
         self.clientproto = 'HTTP/1.1' # not yet initialized
         self.channel.persistent = 0   # force connection close on cleanup
-        self.setResponseCode(http.BAD_REQUEST)
+        self.setResponseCode(http.REQUEST_ENTITY_TOO_LARGE)
         if path in JSON_PATHS: # XXX better json path detection
             self.setHeader('content-type',"application/json")
             body = json_dumps({'reason': 'request max size exceeded'})