Giter Site home page Giter Site logo

postmanlabs / httpbin Goto Github PK

View Code? Open in Web Editor NEW
12.3K 238.0 1.8K 750 KB

HTTP Request & Response Service, written in Python + Flask.

Home Page: https://httpbin.org

License: ISC License

Python 74.53% HTML 25.05% Dockerfile 0.42%
http http-server testing service api json httpbin python

httpbin's Introduction

httpbin's People

Contributors

derflocki avatar dshirley avatar felixpalta avatar flaper87 avatar gaul avatar hkosova avatar jaaap avatar javabrett avatar johnsheehan avatar johtso avatar kennethreitz avatar kevin1024 avatar kingslef avatar kyleconroy avatar luhkevin avatar lukasa avatar marekr22 avatar mozillazg avatar msabramo avatar nateprewitt avatar rochacbruno avatar rochacon avatar sigmavirus24 avatar snh avatar steffenschroeder avatar tatsuhiro-t avatar the-compiler avatar tomviner avatar umbrae avatar zsiciarz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

httpbin's Issues

SSL certificate for HTTPS version is expired

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.

delete endpoint does not work

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>

Method Not Implemented

Invalid method in request

What goes wrong here?

Best regards,
Dietrich

/post does not return multiple values with same key in form data

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'}

IP address returned is no longer correct

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.

Add CORS support

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: *?

/redirect is relative on live site.

> 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

Missing proxy headers

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.

Endpoints don't handle chunked request bodies correctly

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

Request

POST /post HTTP/1.1
Host: httpbin.org
User-Agent: Artax/0.3.0-devel (PHP5.4+)
Transfer-Encoding: chunked

4
test
0

Response

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.

pip install under virtualenv

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

Add /chunked endpoint

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.

oauth 1.0a signing

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

Image endpoint

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:

  • Generate images in code so we don't have any static files. I like this idea, but it might not be a good choice for performance. It may also add a dependency for something like PIL.
  • Include a bunch of static images in the project

/cc @mattt

Request: Include 'httpbin' executable script after installing

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

Add json attribute to responses

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.

Create a "Last-Modified" endpoint

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?

Status endpoint broken for status codes in range 0-199?

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

Support Random Subdomains

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.

/relative-redirect returns an absolute redirect in the live site

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.