forked from orbit-oss/flask
Added debughelpers. Flask will now tell you if you forget enctype
This commit is contained in:
parent
a69b437af7
commit
2e022cb272
3 changed files with 65 additions and 0 deletions
|
|
@ -12,6 +12,7 @@
|
|||
from werkzeug.wrappers import Request as RequestBase, Response as ResponseBase
|
||||
from werkzeug.utils import cached_property
|
||||
|
||||
from .debughelpers import make_enctype_error_multidict
|
||||
from .helpers import json, _assert_have_json
|
||||
from .globals import _request_ctx_stack
|
||||
|
||||
|
|
@ -99,6 +100,16 @@ class Request(RequestBase):
|
|||
return json.loads(self.data, encoding=request_charset)
|
||||
return json.loads(self.data)
|
||||
|
||||
def _load_form_data(self):
|
||||
RequestBase._load_form_data(self)
|
||||
|
||||
# in debug mode we're replacing the files multidict with an ad-hoc
|
||||
# subclass that raises a different error for key errors.
|
||||
ctx = _request_ctx_stack.top
|
||||
if ctx is not None and ctx.app.debug and \
|
||||
self.mimetype != 'multipart/form-data':
|
||||
make_enctype_error_multidict(self)
|
||||
|
||||
|
||||
class Response(ResponseBase):
|
||||
"""The response object that is used by default in Flask. Works like the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue