Request such as `/status/4!9` caused a `ValueError` exception when
trying to cast the status to an int. Now the client is greeted with
`400` and a body of `Invalid status code`.
Fixes#329.
Response.get_data did not exist in older versions of Flask/Werkzeug,
and is even now not documented.
This will make httpbin work with either the new version where it does
exist, and the older versions where it doesn't.
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
This endpoint conforms to RFC7233.
http://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7233.html
It is functionally very similar to /stream-bytes, but it also
allows specifying a "Range" header, which allows the client
to ask for a specific portion of the resource.
I didn't add this functionality to /stream-bytes so as not
to break compatibility with any clients that expect range
requests to fail on that endpoint. Perhaps I'm just being
overly cautious.
It's useful for testing tools which track the progress of a request to know
the content length ahead of time.
Test included. I've verified that the new tests do fail without this change,
response.content_length is None if an explicit Content-Length isn't set.
If you do a "simple" request, there will be no CORS preflight
OPTIONS request. That means that Basic auth will fail over
CORS. This adds the header to all requests, fixing the problem.
Closes#122
The DELETE endpoint was missing form and files, so if you hit the
endpoint with data in the envelope and a Content-Type header set to
application/x-www-form-urlencoded, the data will disappear. Since RFC
2731 doesn't disallow content in the body of a DELETE request, let's
allow that data to pass through
Closes#143
Encoding of the received files and/or body data was failing in case of raw
binary data being POSTed/PUT/etc. (The exact trigger was actually a non-UTF-8
data stream, since Flask's `jsonify`, i.e. `simplejson.dumps` assumes UTF-8.)
Binary data in a JSON response are now encoded as "data" URLs, according to
RFC 2397. "Data" URL scheme was chosen for its simplicity and clarity. MIME
type is included. Plain text is passed thru unmodified, as before.
Also, tests demonstrating the bug/fix added to `test_httpbin.py`.