Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
12.79k stars 478 forks source link

include response bodies in the json output #1907

Open kidbrax opened 1 year ago

kidbrax commented 1 year ago

Problem to solve

I need a way to capture all the response bodies from a series of requests.

Proposal

I'd like to have the response bodies included in the --json output. This way I could filter down to exactly the output I want. Or just return all response bodies from the command instead of just the last one when not using json output.

Additional context and resources

As of now, I am using ver-verbose and redirecting stderr to a file which has all the responses. But hten I have to parse thorugh all the other info that I don't need.

Tasks to complete

jcamiel commented 1 year ago

Hi, it seems reasonable. My only question: what should be the default behaviour of --json? Do we include request and response body by default or to we add another flag (--json-full etc...) to activate it...

kidbrax commented 1 year ago

Good question. When I first used it, I assumed the body would be included in the json by default. Seems unintuitive to include everything else and not the body. Thanks for the follow up!

selfagency commented 11 months ago

for my two cents: i think it should be the default. it struck me as odd that using the --json flag only provided metadata and not the result of the request unless i also added --very-verbose, and then the response came through on stderr instead of stdout. i'd prefer it if including the response body was default behavior but also wish --json-full existed and included all debug data included in the --very-verbose output but as json.

fabricereix commented 11 months ago

now, I would also include it by default. We hadn't included initially mostly to be consistent with the HAR format.

jcamiel commented 11 months ago

See also this discussion

jcamiel commented 10 months ago

See also @iBicha comment => https://github.com/Orange-OpenSource/hurl/discussions/1969#discussioncomment-7418291

fabricereix commented 10 months ago

here a possible solution relating to JSON output and body:

jcamiel commented 3 months ago

--report-json has been merged on master (5.0.0-SNAPSHOT): there is now a report.json file referencing each HTTP responses of the run dumped to disk.