[kwlug-disc] Utility to parse HTTP response

Anton Avramov lukav at lukav.com
Fri Jan 31 10:46:18 EST 2025


Hi William, 

You can have curl do it for you: 

Option 1: Used --output and --dump-headers switches to write the
headers and the body of the request in separate files. Then it is
trivial to get the response code with head -n 1 <header dump file>. 

Option 2: You can use --write-out switch to actually format the output
(including headers, http_code etc) in whatever best works for you.

P.S. looking for the --write-out switch in the manual I see it has: 
json           A JSON object with all available keys. (Added in 7.70.0)
So it would be possible to use that and then jq again.

Cheers
 
On Fri, 2025-01-31 at 01:12 -0500, William Park via kwlug-disc wrote:
> Hi all, (also posted to GTALUG)
> 
> To build HTTP request, you use 'curl'.
> 
> After you get HTTP response, what utility do you use to extract
> stuffs 
> you want?  JSON format has 'jq', and XML format has 'xmlstarlet'. 
> I'm 
> looking for something like that but for HTTP format.
> 
> I know it's simple (HTTP response has 3 parts: first line, headers,
> and 
> body), but I just want to reduce chance of typos.




More information about the kwlug-disc mailing list