I just ran into the same problem, and this is mainly because the Werkzeug validation method does not currently support setting the content_type of DELETE requests.
The code here shows how Werkzeug gets the content type:
def _get_content_type(self): ct = self.headers.get('Content-Type') if ct is None and not self._input_stream: if self.method in ('POST', 'PUT', 'PATCH'): if self._files: return 'multipart/form-data' return 'application/x-www-form-urlencoded' return None return ct
If there is no content_type , the form data never displays it from environ and into the request, so your Flask server does not actually send data.
Ultimately, this is a bug with Werkzeug, because you can create a curl request that uses the DELETE method and also includes form data. I sent a transfer request to the Werkzeug repository to solve this problem. Feel free to call on github: https://github.com/mitsuhiko/werkzeug/pull/620
Refresh . To solve the problem now, you can work around this by explicitly specifying the type of content in your request, for example:
def test_delete(self): rv = self.app.delete('MyEndPoint', data={'arg1', 'val'}, headers={'Content-Type': 'application/x-www-form-urlencoded'})
Update again : the transfer request that I submitted was reviewed, refined and merged and will be included in Werkzeug version 0.10, so hopefully this should not be a problem anymore :)
Kevin
source share