A Kenneth Reitz Project.
Run locally:
docker pull kennethreitz/httpbin
docker run -p 80:80 kennethreitz/httpbin
See http://httpbin.org for more information.
HTTP Request & Response Service, written in Python + Flask.
Home Page: https://httpbin.org
License: ISC License
A Kenneth Reitz Project.
Run locally:
docker pull kennethreitz/httpbin
docker run -p 80:80 kennethreitz/httpbin
See http://httpbin.org for more information.
Can you add support for IPv6 to httpbin.org?
$ wget -6 http://httpbin.org/ip
--2012-07-24 02:04:19-- http://httpbin.org/ip
Resolving httpbin.org... failed: Name or service not known.
wget: unable to resolve host address “httpbin.org”
The URL from all endpoints accessed via HTTPS still shows http://httpbin.org/
instead of the https://
version.
It would be cool to add a /post/upload
endpoint, which returns the file size of the uploaded object.
See: http://en.wikipedia.org/wiki/Shared_Dictionary_Compression_Over_HTTP
Endpoint: /sdch
The /relative-redirect
endpoint is returning an absolute redirect in it's Location
header. The only difference from /redirect
and /relative-redirect
is that the last one has Content-Length: 0
. Here's a sample netcat session:
$ nc httpbin.org 80 << EOF
GET /redirect/200 HTTP/1.1^M
Host: httpbin.org^M
^M
EOF
HTTP/1.1 302 FOUND
Content-Type: text/html; charset=utf-8
Date: Mon, 04 Jun 2012 14:01:04 GMT
Location: http://httpbin.org/redirect/199
Server: gunicorn/0.13.4
Content-Length: 233
Connection: keep-alive
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="/redirect/199">/redirect/199</a>. If not click the link.
$ nc httpbin.org 80 << EOF
GET /relative-redirect/200 HTTP/1.1^M
Host: httpbin.org^M
^M
EOF
HTTP/1.1 302 FOUND
Content-Type: text/html; charset=utf-8
Date: Mon, 04 Jun 2012 14:01:16 GMT
Location: http://httpbin.org/relative-redirect/199
Server: gunicorn/0.13.4
Content-Length: 0
Connection: keep-alive
At the moment, there's no way to test a chunked body decoder. An endpoint which chunks the data would be appreciated, as it would allow testing for proper HTTP/1.1 parsing.
I am trying to unit-test the RequestsLibrary for Robotframework. Unfortunately, the delete test fails.
I can reproduce it with Firefox ReST Client:
DELETE http://httpbin.org/delete
request body:
foo=bar
--> result:
<TITLE>400 Bad Request</TITLE>Invalid method in request
What goes wrong here?
Best regards,
Dietrich
When you omit the "www" in the url when doing a non-GET request, httpbin responds with a 301 moved status.
>> print requests.post('http://httpbin.org/post').status_code
>> 301
>> print requests.post('http://www.httpbin.org/post').status_code
>> 200
It only happens on httpbin.org, not when run locally.
As per RFC 5789, support for a /patch
endpoint should be added.
Virtualenv 1.9.1
Error log:
Found existing installation: distribute 0.7.3
Uninstalling distribute:
Successfully uninstalled distribute
Running setup.py install for distribute
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /home/woozyking/py27/lib/python2.7/site-packages
Non-egg installation
Removing elements out of the way...
Renaming /home/woozyking/py27/lib/python2.7/site-packages/setuptools-0.9.4-py2.7.egg-info into /home/woozyking/py27/lib/python2.7/site-packages/setuptools-0.9.4-py2.7.egg-info.OLD.1373919980.42
Renaming /home/woozyking/py27/lib/python2.7/site-packages/setuptools into /home/woozyking/py27/lib/python2.7/site-packages/setuptools.OLD.1373919980.42
Renaming /home/woozyking/py27/lib/python2.7/site-packages/pkg_resources.py into /home/woozyking/py27/lib/python2.7/site-packages/pkg_resources.py.OLD.1373919980.42
Could not find the /home/woozyking/py27/lib/python2.7/site-packages/site.py element of the Setuptools distribution
Patched done.
Relaunching...
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'install' is not defined
Complete output from command /home/woozyking/py27/bin/python -c "import setuptools;__file__='/home/woozyking/py27/build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-KD61Bg-record/install-record.txt --single-version-externally-managed --install-headers /home/woozyking/py27/include/site/python2.7:
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /home/woozyking/py27/lib/python2.7/site-packages
Non-egg installation
Removing elements out of the way...
Renaming /home/woozyking/py27/lib/python2.7/site-packages/setuptools-0.9.4-py2.7.egg-info into /home/woozyking/py27/lib/python2.7/site-packages/setuptools-0.9.4-py2.7.egg-info.OLD.1373919980.42
Renaming /home/woozyking/py27/lib/python2.7/site-packages/setuptools into /home/woozyking/py27/lib/python2.7/site-packages/setuptools.OLD.1373919980.42
Renaming /home/woozyking/py27/lib/python2.7/site-packages/pkg_resources.py into /home/woozyking/py27/lib/python2.7/site-packages/pkg_resources.py.OLD.1373919980.42
Could not find the /home/woozyking/py27/lib/python2.7/site-packages/site.py element of the Setuptools distribution
Patched done.
Relaunching...
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'install' is not defined
----------------------------------------
Rolling back uninstall of distribute
Command /home/woozyking/py27/bin/python -c "import setuptools;__file__='/home/woozyking/py27/build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-KD61Bg-record/install-record.txt --single-version-externally-managed --install-headers /home/woozyking/py27/include/site/python2.7 failed with error code 1 in /home/woozyking/py27/build/distribute
/bytes/:n
, /stream-bytes/:n
, /links/:n
endpoints are returning 404. The required view functions are added in kennethreitz@414a719#L2R370, seems like server needs a restart ?
The following Frisby test demonstrates this best:
var frisby = require('frisby');
frisby.create('Ensure response has proper JSON types in specified keys')
.post('http://httpbin.org/post', {
arr: [1, 2, 3, 4],
foo: "bar",
bar: "baz",
answer: 42
}, {json: true})
.expectJSONTypes('data', {
arr: Array,
foo: String,
bar: String,
answer: Number
})
.inspectBody()
.toss()
Returned response is:
{ origin: '127.0.0.1',
files: {},
form: {},
headers:
{ 'Content-Length': '53',
'X-Forwarded-Port': '80',
Connection: 'keep-alive',
Host: 'httpbin.org',
Cookie: '',
'Content-Type': 'application/json' },
url: 'http://httpbin.org/post',
args: {},
data: '{"arr":[1,2,3,4],"foo":"bar","bar":"baz","answer":42}' }
Which renders the "data" key in a way that can't be run through JSON.parse() in node.js. This should be returned in full JSON glory instead of packed in a string.
For JSON loads/dumps, would ujson improve performance by a lot compare to simplejson used in this case?
I'm trying to port my urllib3 tests to use httpbin, and it would be extra convenient if when I did pip install httpbin
, it installed an httpbin
script into my virtualenv's bin
dir for running it.
Kind of ironic that httpbin doesn't have a bin. ;)
It would be useful to be able to set multiple cookies at once so that server would return more than one set-cookie
header. The need came out while investigating urllib3/urllib3#3
> curl -v http://httpbin.org/redirect/1
* About to connect() to httpbin.org port 80 (#0)
* Trying 23.23.206.95...
* connected
* Connected to httpbin.org (23.23.206.95) port 80 (#0)
> GET /redirect/1 HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: httpbin.org
> Accept: */*
>
< HTTP/1.1 302 FOUND
< Content-Type: text/html; charset=utf-8
< Date: Tue, 11 Jun 2013 02:28:25 GMT
< Location: /get
< Server: gunicorn/0.17.4
< Content-Length: 215
< Connection: keep-alive
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
* Connection #0 to host httpbin.org left intact
<p>You should be redirected automatically to target URL: <a href="/get">/get</a>. If not click the link.* Closing connection #0
If the client fails to send Content-length: 0
on a blank POST, /post
will report it anyway:
https://github.com/kennethreitz/requests/issues/223#issuecomment-5501503
/headers
will send back Connection: Keep-alive
even when the client sent Connection: close
:
When visiting through a proxy these headers were missing:
HTTP_X_PROXY_ID, HTTP_VIA, HTTP_X_FORWARDED_FOR
I confirmed they were visible by checking against http://proxydetect.com/
I just checked the source and I see these and other headers are intentionally deleted. Please consider displaying them as they are valuable for some of us.
Create an endpoint that allows you to specify a date/time, and will respond with a Last-Modified
header containing that date.
If the request is sent with an If-Modified-Since
header, a 304 Not Modified
response should be returned.
Does this sound like something that could be useful?
For Logs, Stats, and Exceptions.
for testing hashes.
setup httpbin.org service on another port too, 8080 for example, so that we can also test non standard ports in http
As discussed in AFNetworking/AFNetworking#1075 this is an issue for adding an image endpoint.
I'll convert this to a pull request tomorrow. But just so we can figure out how to do this I have created an issue right now.
Would be great to have an endpoint which would support multiple types like as follows:
> GET /image HTTP/1.0
> Accept: image/png
< Content-type: image/png
> GET /image HTTP/1.0
> Accept: image/jpeg
< Content-type: image/jpeg
> GET /image HTTP/1.0
> Accept: image/*
< Content-type: image/png
There are two options we have:
/cc @mattt
It'd be cool to test the ability of an http client to correctly sign oauth requests
e.g. hardcode four values: consumer key/secret, user token/secret, return 200 if you signed the request properly
I don't have much experience with WSGI, but this may be a simple fix as per a similar issue over at StackOverflow.
Endpoints do not appear to handle chunked request bodies correctly. The following is a raw request message to demonstrate and the corresponding raw response message ...
POST /post HTTP/1.1
Host: httpbin.org
User-Agent: Artax/0.3.0-devel (PHP5.4+)
Transfer-Encoding: chunked
4
test
0
HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 24 Jun 2013 17:23:18 GMT
Server: gunicorn/0.17.4
Content-Length: 297
Connection: keep-alive
{
"origin": "66.57.216.51",
"files": {},
"form": {},
"url": "http://httpbin.org/post",
"args": {},
"headers": {
"Transfer-Encoding": "chunked",
"Host": "httpbin.org",
"Connection": "close",
"User-Agent": "Artax/0.3.0-devel (PHP5.4+)"
},
"json": null,
"data": ""
}
As you can see, the response is unaware of the request's body data.
it's time.
Yeah eh? Maybe? :)
In order to test proper handling of 303/307 codes, POST/PUT/DELETE should be allowed to the /status
endpoints.
Endpoint: /basic-auth
A few dependencies are still missing;
Raw POST request data:
POST http://www.httpbin.org/post HTTP/1.1
Host: www.httpbin.org
Content-Length: 7
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: identity, deflate, compress, gzip
Accept: */*
User-Agent: python-requests/0.8.2
foo=bar&foo=baz
Response:
>> r = requests.post('http://www.httpbin.org/post', data={'foo': ['bar', 'baz']})
>> json.loads(r.content)['form']
>> {u'foo': u'bar'}
Looks like the SSL cert for the (awesome) HTTPS version of httpbin.org has expired
$ openssl s_client -connect httpbin.org:443 | openssl x509 -noout -enddate
depth=0 serialNumber = VfPfjnJUJZ/LfEDvEOwYu/2VX2Jg1/AW, C = US, O = httpbin.org, OU = GT16068112, OU = See www.rapidssl.com/resources/cps (c)11, OU = Domain Control Validated - RapidSSL(R), CN = httpbin.org
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 serialNumber = VfPfjnJUJZ/LfEDvEOwYu/2VX2Jg1/AW, C = US, O = httpbin.org, OU = GT16068112, OU = See www.rapidssl.com/resources/cps (c)11, OU = Domain Control Validated - RapidSSL(R), CN = httpbin.org
verify error:num=27:certificate not trusted
verify return:1
depth=0 serialNumber = VfPfjnJUJZ/LfEDvEOwYu/2VX2Jg1/AW, C = US, O = httpbin.org, OU = GT16068112, OU = See www.rapidssl.com/resources/cps (c)11, OU = Domain Control Validated - RapidSSL(R), CN = httpbin.org
verify error:num=21:unable to verify the first certificate
verify return:1
notAfter=Sep 27 14:09:21 2012 GMT
Let me know if there's anything I can do to get it updated. I'm handy with server stuff.
HTTP/1.1 200 OK
Connection: close
Content-Length: 31
Content-Type: application/json
Date: Sun, 24 Feb 2013 06:52:59 GMT
Server: gunicorn/0.16.1
{
"origin": "10.141.129.99"
}
...
is invalid file name under Windows. Such a file is in templates
folder and when cloning repo on Windows I get
error: unable to create file httpbin/templates/... (Is a directory)
error.
See http://stackoverflow.com/questions/13040577/
no one cares
Would be useful if you wanted to test long-running requests. What do you think? Happy to make the change.
http://httpbin.org/status/500 is great. It would be cool if we could "emulate" an unreliable web server, by having the status code sometimes be 200, and sometimes be 500. Obviously we would want to pick from a set of chosen status codes.
http://httpbin.org/status/200:0.9,500:0.1
or something like that.
C:>curl -vv httpbin.org/status/100
- About to connect() to httpbin.org port 80 (#0)
- Trying 204.236.238.79...
- connected
- Connected to httpbin.org (204.236.238.79) port 80 (#0)
GET /status/100 HTTP/1.1
User-Agent: curl/7.25.0 (i386-pc-win32) libcurl/7.25.0 OpenSSL/0.9.8u zlib/1.2.6 libssh2/1.4.0
Host: httpbin.org
Accept: /- Empty reply from server
- Connection #0 to host httpbin.org left intact
curl: (52) Empty reply from server- Closing connection #0
suggestion: add the ability to delayed responses - this would be useful for testing timeouts on clients.
I wanted to use this with jQuery from Chrome today and saw that my request was cancelled to to Chrome. Would it work to enable CORS by responding to OPTIONS calls with Access-Control-Allow-Origin: *
?
At https://github.com/kennethreitz/httpbin/blob/master/httpbin/core.py#L225 the chunk delimiter is hard-coded as Unix LF. However big stream producers like Twitter use CR + LF as their default chunk delimiter.
What would be an elegant and reasonable way to make this configurable? By passing a URL parameter?
Cheers
If I do:
import requests
print requests.get('http://httpbin.org/get').json()['origin']
I get the wrong IP address. Same happens every other place I test this from.
http://httpbin.org/headers returns ":("
Same for /get and probably others.
However, running the latest code on my machine works. And I think it worked a few days ago.
I'm in the process of writing tests for AFNetworking that focuses on some of the SSL features of the framework. Unfortunately, there is no way to reset the TLS cache system in iOS, so my hands are tied right now in terms of resetting state to verify various test scenarios pass/fail as expected.
Based on a Tech Q&A doc from Apple, this can be worked around by hitting a custom subdomain to force TLS to re-authenticate.
Would it be possible to support any custom subdomain, allowing me to hit something like https://testScenerio1.httpbin.org, and have it function correctly?
Thanks for the great work here.
I was trying to find a file to fix for you, but I don't see where the home page is kept. Thanks for this BTW. Awesome work!
In core.py
there are the following imports
import newrelic.agent
from raven.contrib.flask import Sentry
However these dependencies are not present in setup.py
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.