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.
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.