Commit Graph

51 Commits

Author SHA1 Message Date
kennethreitz 341ddcc471 Merge pull request #312 from felixpalta/Runscope-GH-296-fix-drip-with-zero-numbytes
Fix error 500 on drip due to division by zero (issue #296)
2017-03-16 20:21:09 -04:00
kennethreitz 519196d5ab fix failing test 2017-03-16 19:56:09 -04:00
kennethreitz 65e6a05d0b Merge pull request #319 from puiterwijk/fix-response
Use Response.data with older Werkzeug versions
2017-03-14 17:10:56 -04:00
Tuomas Lappeteläinen 94e64b4598 status/code: return 400 on invalid status code
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.
2017-02-19 16:00:59 +02:00
Patrick Uiterwijk 512fbbd610 Use Response.data with older Werkzeug versions
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>
2016-12-30 21:07:48 +00:00
Felix Palta bba7dd8ee4 Add test for drip with invalid numbytes parameter 2016-12-04 23:46:00 +03:00
Felix Palta 45058da872 Minor refactoring of _test_digest_auth
Instead of joining encoded (binary) strings, join unicode strings first, then encode result, which leads to shorter and clearer code.
2016-12-04 21:31:52 +03:00
Felix Palta 562a60bc23 Update comments, minor fixes 2016-12-04 00:41:02 +03:00
Felix Palta ec17414e94 Enable test cases for Digest auth requests with or without body
When quality-of-protection (qop) is 'auth-int', the hash of request body is used to create digest response.
2016-12-04 00:25:42 +03:00
Felix Palta 9816125df3 Add test for different combinations of digest auth parameters 2016-12-04 00:17:03 +03:00
Felix Palta ada6bd1508 Check response status code in test_digest_auth_with_wrong_password() 2016-12-03 23:34:00 +03:00
Felix Palta f198dab947 Add test implementation for Digest authentication
It can be used for testing of all available combinations of qop (auth/auth-int/not specified) and algorithms (MD5, SHA-256).
2016-12-03 23:31:08 +03:00
Ian Cordasco 6f5d34f730 Merge branch 'master' of https://github.com/Jaaap/httpbin into digest-auth-sha256
Conflicts:
    httpbin/templates/httpbin.1.html
2016-08-10 19:47:51 -05:00
tzickel aea465074e Added supports for non-get redirect-to with other status_code (#284) 2016-08-10 06:20:18 -05:00
teijsden 82e67ed210 Made the Digest algorithm code backwards compatible with old URL style, /digest-auth/auth/user/passwd now works again 2015-11-06 13:48:12 +01:00
teijsden 14b7f46c71 Added support for another Digest algorithm, SHA256. 2015-11-04 15:30:01 +01:00
Florian Bruhin 6858420e24 Turn off tracking unless HTTPBIN_TRACKING is set.
Fixes #245.
2015-08-31 20:49:12 +02:00
David Shirley 60b0ada6f1 Fixed unit tests for python3.4 2015-02-19 11:41:43 -08:00
David Shirley 7e18da5ae9 Renamed endpoint /range-request -> /range 2015-01-26 13:51:47 -08:00
David Shirley e73f34e335 Added a /range-request endpoint
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.
2015-01-02 13:22:42 -08:00
Eduardo Gurgel 54fc281ef7 Fix /redirect to return absolute URL 2014-12-23 19:31:44 +13:00
John Sheehan b16206b80a Merge pull request #184 from msabramo/travis
Add .travis.yml for Travis CI
2014-12-22 16:51:40 -08:00
Marc Abramowitz 6ad0781991 Fix Travis py34 failure
by not relying on core.pyc file in test
2014-12-22 16:37:07 -08:00
John Sheehan 5858e3d434 Merge branch 'GH-168' of https://github.com/msabramo/httpbin into msabramo-GH-168 2014-12-22 16:21:21 -08:00
John Sheehan 6930f8225d Merge pull request #160 from rictic/master
Send an explicit Content-Length header with /drip/
2014-12-22 16:19:10 -08:00
Marc Abramowitz 24dadf082c GH-168: Add newline to end of page
Fixes GH-168
2014-12-22 16:18:12 -08:00
John Sheehan 6dc5270b57 Merge pull request #158 from derflocki/wp-allow-headers
support Access-Control-Request-Headers
2014-12-22 16:15:05 -08:00
Marc Abramowitz 941033ddd2 GH-125: Support multiple headers with same key
Fixes: GH-125
2014-11-29 06:19:30 -08:00
Peter Burns 5021b420ef Send an explicit Content-Length header with /drip/
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.
2014-09-18 16:03:19 -07:00
derflocki 43ced62b44 support Access-Control-Request-Headers 2014-09-09 21:26:25 +02:00
Ivan Júnior 24025f4a61 drip endpoint: adding custom status support 2014-08-08 18:10:01 -03:00
Kevin McCarthy 540b414490 Try to decode bytestrings from UTF8 in json_safe
Closes #148
2014-07-06 10:27:17 -10:00
Kevin McCarthy 320e994c30 Add Access-Control-Allow-Credentials to All
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
2014-06-21 15:51:24 -10:00
Kevin McCarthy f6d708ebe5 Check X-Forwarded-Proto when returning the url
Closes #31
2014-06-21 14:16:42 -10:00
Kevin McCarthy 5ee70566ec Fix Digest Auth to Return Correct Header
Digest Auth was returning the wrong header when a login attempt failed.

Closes #133
2014-06-21 13:58:36 -10:00
Kevin McCarthy f3f136581a pep8 cleanup on tests 2014-06-21 12:48:00 -10:00
Kevin McCarthy 745f9b5009 Add test for XML endpoint 2014-06-21 12:34:22 -10:00
Kevin McCarthy b2cb8678f3 Status Endpoint should Accept All HTTP Verbs
Closes #32 (again)
2014-06-21 12:16:00 -10:00
Kevin McCarthy 2593a8ab67 Add form and files to DELETE Endpoint
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
2014-06-21 11:53:44 -10:00
Kevin McCarthy 0c44ec9233 Restore random seed function for byte endpoints
os.urandom() ignores random.seed(), so I'm restoring the use of
random.randint in a python3 compatible way.
2014-06-08 22:09:25 -10:00
Kevin McCarthy 7e2214ce14 fix byte streaming endpoint in python3 2014-06-08 17:49:58 -10:00
Kevin McCarthy 16d6fea9b8 Fix bytes endpoint in python3 2014-06-08 17:49:58 -10:00
Kevin McCarthy 32c842f06f Fix bug that was causing POSTs missing a content-type header to 500
Closes #141
2014-06-05 18:00:52 -10:00
Kevin McCarthy 782a3411a7 Add Python3 Support
I mostly just added a bunch of encoding, especially around the HTTP
Digest Auth stuff.  This commit also adds six as a dependency.
2014-05-25 19:44:07 -10:00
Rodrigo Chacon e3cd47d0e2 Use header Origin in response headers when available
Since the RFC [1] doesn't allow wildcards for credentialed requests,
add the requested Origin into the response headers.

[1] https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS#Requests_with_credentials
2013-04-24 19:33:18 -03:00
Rodrigo Chacon 50ddd78b89 PEP8 2013-04-24 19:33:18 -03:00
Rodrigo Chacon 11a8c78aa5 Adding support for preflight request headers
Just as stated in http://www.w3.org/TR/cors/#preflight-request, we must return some extra headers when dealing with preflight (HTTP OPTIONS method) requests.
2013-04-24 19:33:18 -03:00
Rodrigo Chacon 61bed33f24 Adding CORS support for all requests 2013-04-24 19:33:18 -03:00
Radomir Stevanovic 9a56bb8dd0 bugfix: JSON-safe encoding of raw binary data/files
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`.
2012-08-14 22:57:35 +02:00
Radomir Stevanovic 213d03a090 init fixes (git, pip & test related)
- gitignored: *.pyc, env/
  - gevent added to requirements.txt
  - test_httpbin syntax error fix
2012-08-14 20:43:35 +02:00