jgi-kbase / IDMappingService

Service for mapping data IDs between namespaces.
MIT License
0 stars 2 forks source link

Don't require a content-type header with curl #97

Closed MrCreosote closed 5 years ago

MrCreosote commented 5 years ago

If you do curl -d, curl sends a form encoded content type. If you touch the request, even to get headers, flask will parse the body and make the raw data inaccessible. Hence, even if your server only accepts json, you always have to specify content type with curl.

doing request.get_data() before touching anything else caches the raw data.

What's really great is the flask docs (http://werkzeug.pocoo.org/docs/0.14/wrappers/#werkzeug.wrappers.BaseRequest.get_data) say not to call get_data() before checking the content length, but AFAICT getting the content length header will cause the entire body to be parsed, as request.get_data() is None after checking the auth header unless you call get_data() before parsing the header.

This is quite frustrating.

ADDENDUM: I'm stupid, and you can just call get_data() whenever you need to. I fix this in a later PR.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 206


Totals Coverage Status
Change from base Build 205: 0.01%
Covered Lines: 1037
Relevant Lines: 1091

💛 - Coveralls