Using httpbin to test http/https requests
Posted by jpluimers on 2015/09/15
StackOverflow user Kenneth Reitz has written a great on-line and free httpbin tool that responds to many kinds of http/https requests including the standaard http request methods (or verbs) used by REST: get
, post
(for http 1.0) and patch
, put
, delete
(for http 1.1).
These verbs are not supported: head
(http 1.0) and trace
, options
, connect
(http 1.1).
The site is geared towards JSON (as most the responses are in JSON, except for one XML response and a few TEXT responses), but even if your environment does not use JSON, it is very useful as you basically get an echo of information on what you pass to it.
Except one endpoint (/encoding/utf8), none of the response encodings can be determined by the request. This is a pity as sometimes it is good to see how a specific encoding works for JSON, but it is very hard to support encodings well, so I can understand the support is not there (or not there yet).
There are many examples on the site, which I won’t list.
There are at least two sites hosting them. The original supports HTTP and HTTPS only, but the ngHttp2 people also support HTTP2 and SPDY:
- httpBin: [WayBack] httpbin.org 0.9.0: A simple HTTP Request & Response Service.
- ngHttp2: [WayBack] httpbin(1): HTTP Client Testing Service
What I do list are the endpoints as copied from the site on 20141228:
/
This page./ip
Returns Origin IP./user-agent
Returns user-agent./headers
Returns header dict./get
Returns GET data./post
Returns POST data./patch
Returns PATCH data./put
Returns PUT data./delete
Returns DELETE data/encoding/utf8
Returns page containing UTF-8 data./gzip
Returns gzip-encoded data./deflate
Returns deflate-encoded data./status/:code
Returns given HTTP Status code./response-headers?key=val
Returns given response headers./redirect/:n
302 Redirects n times./redirect-to?url=foo
302 Redirects to the foo URL./relative-redirect/:n
302 Relative redirects n times./cookies
Returns cookie data./cookies/set?name=value
Sets one or more simple cookies./cookies/delete?name
Deletes one or more simple cookies./basic-auth/:user/:passwd
Challenges HTTPBasic Auth./hidden-basic-auth/:user/:passwd
404’d BasicAuth./digest-auth/:qop/:user/:passwd
Challenges HTTP Digest Auth./stream/:n
Streams n–100 lines./delay/:n
Delays responding for n–10 seconds./drip?numbytes=n&duration=s&delay=s&code=code
Drips data over a duration after an optional initial delay, then (optionally) returns with the given status code./html
Renders an HTML Page./robots.txt
Returns some robots.txt rules./deny
Denied by robots.txt file./cache
Returns 200 unless an If-Modified-Since or If-None-Match header is provided, when it returns a 304./cache/:n
Sets a Cache-Control header for n seconds./bytes/:n
Generates n random bytes of binary data, accepts optional seed integer parameter./stream-bytes/:n
Streams n random bytes of binary data, accepts optional seed and chunk_size integer parameters./links/:n
Returns page containing n HTML links./forms/post
HTML form that submits to /post/xml
Returns some XML
–jeroen
via: [Wayback] HTTP Test server that accepts GET/Post calls – Stack Overflow.
Leave a Reply