httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.92k stars 3.68k forks source link

Add "light response header" to --print options #687

Open rherrick opened 6 years ago

rherrick commented 6 years ago

This is similar to #588, but simpler. Rather than wanting to be able to limit the header fields displayed based on configuration or criteria, it would be really useful to have a light or quiet response header option. A lot of data is in those headers, most of which isn't very informative unless you're specifically looking for something in, e.g., the content security policy or content type or whatever. Most of the time we really only care about the response status code. In some cases, e.g. 30x responses, you'd want a bit more information, like the Location header.

I often find myself needing to copy and paste a lot of output when working on documentation or capturing data for debugging purposes. I want to have the response status code, but I don't need all the other baggage. This means I start with this:

$ http --session=admin --verify=no POST https://server/REST/call <<< '["localdb"]'
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 0
Content-Security-Policy: frame-ancestors 'self'
Date: Mon, 09 Jul 2018 21:19:49 GMT
Server: nginx/1.10.3 (Ubuntu)
Set-Cookie: SESSION_EXPIRATION_TIME="1531171189374,900000"; Version=1; Path=/
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

I then have to go back and delete all of the HTTP headers by hand so that the resulting text is readable.

Don't get me wrong, it's worlds better than curl ;) In fact, this is really the only suggestion I have for improving httpie, it's a fantastic tool and I'm grateful for all the work that's gone into it!

Yogita98 commented 4 years ago

Is this issue up for grabs?