Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output request/response headers to stderr #41

Open
dylanowen opened this issue Feb 13, 2020 · 1 comment
Open

Output request/response headers to stderr #41

dylanowen opened this issue Feb 13, 2020 · 1 comment
Labels

Comments

@dylanowen
Copy link
Contributor

@dylanowen dylanowen commented Feb 13, 2020

I've been using dot-http for some scripting tasks, it'd be nice to have the response body be the only thing output over stdout, much like curl.

https://github.com/bayne/dot-http/compare/master...dylanowen:stderr?expand=1

@bayne

This comment has been minimized.

Copy link
Owner

@bayne bayne commented Feb 15, 2020

I wanted to reserve stderr for other purposes (eventually wanting to print out metrics such as request time etc)

My end-goal was to have a --response-output-format="FORMAT_STRING_HERE" where the format string could be constructed to suppress the headers. As a convenience, I'm imagining creating flags that are synonymous to an expanded form of --response-output-format="FORMAT_STRING_HERE"

For example, if we had a response like

POST http://httpbin.org/post

HTTP/1.1 200 OK
date: Sat, 15 Feb 2020 19:29:22 GMT

{
  "origin": "127.0.0.1",
  "url": "http://httpbin.org/post"
}

The response format string would be %R\n%S\n%H\n%B where

  • %R is POST http://httpbin.org/post
  • %S is HTTP/1.1 200 OK
  • %H are the headers
  • %B is the body

So to solve your problem, I would want the solution to be:

--only-output-body

which is synonymous with

--response-output-format="%B"

For the time being (since none of the response format exists yet), a mergeable change would be to:

  1. Create a new flag --only-output-body
  2. Update the response handler to prevent printing other parts of the response when that flag is set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.