Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
120 lines (95 sloc) 2.63 KB
--- Examples against httpbin.org ---
---
Examples of how some requests to _httpbin.org_ can be specified. Read more about
the httpbin.org API at http://httpbin.org/.
See ../README.md for details on how to test this specification.
---
# First request and response
Get a teapot from some full URL.
Leading or trailing blank lines in the body are stripped, unless you delimit
the body lines with the markers <<< (start) and >>> (end). The newlines after
<<< as well as the newline before >>> is not included in the body.
GET /status/418
> Accept: *
> User-Agent: KATT
> Host: {{<hostname}}:{{<port}}
< 418
< X-More-Info: http://tools.ietf.org/html/rfc2324
<<<
-=[ teapot ]=-
_...._
.' _ _ `.
| ."` ^ `". _,
\_;`"---"`|//
| ;/
\_ _/
`"""`
>>>
# Second request and response
Get unauthorized.
Also note that we don't expect any body.
The current date will be available to use in later requests as `{{<some_date}}.`
GET /status/401
> Accept: *
> User-Agent: KATT
< 401
< Www-Authenticate: Basic realm="Fake Realm"
< Date: {{>some_date}}
# Third request
Note that the title of this operation is "Third request", but that's just
markdown for you. You don't need to include a title, or even a description of
the operations unless you want to. In the fourth request will will skip the
description altogether.
Here we are getting a cached response.
GET /cache
> Accept: application/json
> User-Agent: KATT
< 200
< Content-Type: application/json
{
"url": "http://httpbin.org/cache",
"headers": "{{_}}",
"args": "{{_}}",
"origin": "{{>origin}}"
}
GET /cache
> Accept: application/json
> User-Agent: KATT
> If-Modified-Since: {{<some_date}}
< 304
A fifth request to show that whitespace in JSON body is insignificant.
POST /post
> Accept: application/json
> Content-Type: application/json
> User-Agent: KATT
{"origin":"{{<origin}}","whoarewe":"{{<your_name}}_and_{{<my_name}}","date":"{{<some_date}}"}
< 200
< Content-Type: application/json
{
"args": "{{_}}",
"data": "{{>raw_data}}",
"files": [],
"form": [],
"headers": "{{_}}",
"origin": "{{<origin}}",
"url": "http://httpbin.org/post",
"json": {
"origin": "{{<origin}}",
"date": "{{<some_date}}",
"whoarewe": "{{>whoarewe}}"
}
}
GET /get?origin={{<origin}}&whoarewe={{<whoarewe}}
> Accept: application/json
> User-Agent: KATT
< 200
< Content-Type: application/json
{
"args": {
"whoarewe": "{{<your_name}}_and_{{<my_name}}",
"origin": "{{<origin}}"
},
"headers": "{{_}}",
"origin": "{{_}}",
"url": "http://httpbin.org/get?origin={{<origin}}&whoarewe={{<whoarewe}}"
}