Skip to content

Response

Responses can also be specified within an http file. This feature is mainly intended for documentation purposes.

Response Documentation

Once a line starts with HTTP/{version}} , the following content is interpreted as a response and parsed.

HTTP
GET https://httpbin.org/get

HTTP/1.1 200 - OK
date: Mon, 21 Jun 2021 19:38:05 GMT
content-type: application/json
content-length: 295
connection: close
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true

{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Host": "httpbin.org",
    "User-Agent": "httpyac",
    "X-Amzn-Trace-Id": "Root=1-60d0ea9d-3dfb873f497a9e6d50b2eccc"
  },
  "origin": "79.243.57.74",
  "url": "https://httpbin.org/get"
}

WARNING

The response is not used further in the program. Instead, it is only used to initially set up the display in httpbook correctly, for example.

Output Redirection

httpYac canc redirect response body to a custom file. It supports two operators:

  • >> operator always creates a new file, adding an -n suffix to a file name if the requested file name already exists.
HTTP
GET  https://httpbin.org/anything

>> ./outputRedirection.json
  • >>! operator overrides the file, if it already exists.
HTTP
GET  https://httpbin.org/anything

>>! ./outputRedirection.json