Httpie: Print request headers regardless of connection error

Created on 7 Dec 2017  ·  4Comments  ·  Source: httpie/httpie

If -v is set in the command line arguments HTTPie prints the request along with the response.

The request is however not printed if a connection error happened, eg. the connection was closed by server before receiving a response.

I think it would be helpful to see the request printed in such case for debugging purposes.

> http -v GET http://127.0.0.1:1234/
http: error: ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)) while doing GET request to URL: http://127.0.0.1:1234/

In the above case the server closed the connection _after_ the request was completely sent.

Running httpie 0.9.9, detailed debug output attached:
httpie-debug.txt attached

feature planned

Most helpful comment

This is definitely a wanted feature. It applies to the request body as well. It should be possible to just construct an HTTP request and print it out without actually making it, something like http --dry-run example.org.

I'm afraid, though, that this will need a larger refactoring of the output machinery. Functionality affected by --all, --download, etc. will need to be updated.

I'm working (very slowly) on streaming uploads (when done, ~v1.0.0~ v2.0.0 will go out), and for that I'm changing the parts of the codebase that take care of output quite a bit. I'll see if I can squeeze in this feature as well.

All 4 comments

Can I submit a pull request for this feature?

@dejicranium as the issue reporter I have nothing against you submitting a PR. :-)

This is definitely a wanted feature. It applies to the request body as well. It should be possible to just construct an HTTP request and print it out without actually making it, something like http --dry-run example.org.

I'm afraid, though, that this will need a larger refactoring of the output machinery. Functionality affected by --all, --download, etc. will need to be updated.

I'm working (very slowly) on streaming uploads (when done, ~v1.0.0~ v2.0.0 will go out), and for that I'm changing the parts of the codebase that take care of output quite a bit. I'll see if I can squeeze in this feature as well.

This has now been pushed to master in bece3c77bb51ecc55dcc4008375dc29ccd91575c and it will be released when v2.0.0 comes out. Each request and response is now handled independently as they are available. Also added --offline for dry runs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chuma picture chuma  ·  3Comments

cunde picture cunde  ·  7Comments

eliangcs picture eliangcs  ·  5Comments

poskadesign picture poskadesign  ·  7Comments

pyvotal-cguers picture pyvotal-cguers  ·  5Comments