hurl icon indicating copy to clipboard operation
hurl copied to clipboard

include response bodies in the json output

Open kidbrax opened this issue 2 years ago • 8 comments

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

  • [ ] ...

kidbrax avatar Sep 08 '23 21:09 kidbrax

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...

jcamiel avatar Sep 09 '23 08:09 jcamiel

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!

kidbrax avatar Sep 09 '23 15:09 kidbrax

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.

selfagency avatar Sep 27 '23 00:09 selfagency

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

fabricereix avatar Sep 27 '23 06:09 fabricereix

See also this discussion

jcamiel avatar Sep 28 '23 09:09 jcamiel

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

jcamiel avatar Oct 29 '23 23:10 jcamiel

here a possible solution relating to JSON output and body:

  • keep --json option as it is now (without body)
  • add --report-json option similar to --report-html that will keep all the responses in separate files without escaping. The JSON will simply includes the filename.
  • in order to get response in the output, use the write-out option
  • add --json-full option with all available data (body included in base64)

fabricereix avatar Nov 08 '23 13:11 fabricereix

--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.

jcamiel avatar Jun 09 '24 19:06 jcamiel