xh
xh copied to clipboard
Support outputting the metadata of a response
This PR adds support for outputting response's elapsed time as part of a new metadata section which can be enabled via either --print=m, a double invocation of the verbose flag i.e -vv, or via the --meta flag (similar to --headers and --body).
The duration of a response's elapsed time begins from when a request is made and ends when the response has been fully printed.
$ xh -vv httpbin.org/status/418
GET /status/418 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Host: httpbin.org
User-Agent: xh/0.15.0
HTTP/1.1 418 I'm a teapot
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Length: 135
Date: Sat, 12 Mar 2022 21:30:13 GMT
Server: gunicorn/19.9.0
X-More-Info: http://tools.ietf.org/html/rfc2324
-=[ teapot ]=-
_...._
.' _ _ `.
| ."` ^ `". _,
\_;`"---"`|//
| ;/
\_ _/
`"""`
Elapsed time: 0.37325s
Ticks another item from #4
I need to add tests + update the documentation for the --verbose flag.
I think this PR is ready now. I will merge it and we can fix any found issues later