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

Add option to always print response body #1745

Open
1 task
Lythenas opened this issue Jul 8, 2023 · 4 comments
Open
1 task

Add option to always print response body #1745

Lythenas opened this issue Jul 8, 2023 · 4 comments
Labels
Milestone

Comments

@Lythenas
Copy link
Contributor

Lythenas commented Jul 8, 2023

Problem to solve

I would like to see all response bodies (not just the last). For me this is most useful with --verbose but it might also be useful without that flag.

I know that --very-verbose already prints all response bodies but that has a lot more other information that I don't really want or need to see (like the timing, dns and ssl debug logs).

Additionally it might be good to also add this to the html and json output.

Proposal

I would suggest adding a flag (maybe --all-output) that enables printing all response bodies.

Additional context and resources

This is mostly useful for debugging (or retracing) a failed test in cases where asserts and captures can't easily do that.

An alternative would be to add a capture for the entire body after every request in hurl (which would also be displayed with --verbose).

Tasks to complete

  • ...
@Lythenas Lythenas added the enhancement New feature or request label Jul 8, 2023
@jcamiel
Copy link
Collaborator

jcamiel commented Jul 8, 2023

You have also --error-format=long that prints body response and headers in case of errors

@jcamiel
Copy link
Collaborator

jcamiel commented Jul 13, 2023

So there are two options:

  • for debugging purpose, one can use --error-format=long to display response body and response headers and failed error. This is already supported in Hurl 4.0.0
  • we could also support a way to print properties for each response of an Hurl file to sdtout/sdterr. With curl, there is --write-out. By implementing --write-out, we could do the following:
$ hurl --write-out "Code %{response_code}"
Code 200
Code 200
Code 404

This way, printing each body response could be:

$ hurl --write-out "%{response}"
<html><body><...></body></html>
<html><body><...></body></html>
<html><body><...></body></html>

--write-out is not implemented yet but it could be a nice addition

Also, we could support --write-out in [Options]section to output a particular response:

GET https://foo.com/1

GET https://foo.com/2

GET https://foo.com/3
[Options]
write-out: "Code %response_code" 

@jcamiel
Copy link
Collaborator

jcamiel commented Jun 11, 2024

@Lythenas a small workaround for this issue is to use --output on a request:

# Output response to standard output using `-`
GET https://foo.com
[Options]
output: -

GET https://bar.com

GET https://baz.com

@jcamiel
Copy link
Collaborator

jcamiel commented Sep 18, 2024

@fabricereix @lepapareil we will this option name --output-all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants