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

repeat responses are lost with --json formatting option #69

Closed
dinurp opened this issue Jun 7, 2023 · 2 comments
Closed

repeat responses are lost with --json formatting option #69

dinurp opened this issue Jun 7, 2023 · 2 comments

Comments

@dinurp
Copy link
Contributor

dinurp commented Jun 7, 2023

I am trying to find the response times of repeated request. I saw that the timings in the response would be useful for this.
httpyac send post.http -n post --repeat 2 --repeat-mode serial > .\post-log.json
after cleaning up the file,

jq '.responses[].timings' .\post-log.json
{
  "wait": 3,
  "dns": 10,
  "tcp": 196,
  "tls": 397,
  "request": 1,
  "firstByte": 200,
  "download": 4,
  "total": 811
}
{
  "wait": 3,
  "dns": 11,
  "tcp": 208,
  "tls": 407,
  "request": 0,
  "firstByte": 208,
  "download": 0,
  "total": 837
}

But, if I try to use the option --json to get the response in a easily parsed format, the output does not contain the responses from repeated requests. It only contains one response.

httpyac send post.http -n post --repeat 2 --repeat-mode serial --json > .\post-log.json

jq '.requests[].response.timings' .\post-log.json
{
  "wait": 2,
  "dns": 10,
  "tcp": 205,
  "tls": 407,
  "request": 0,
  "firstByte": 207,
  "download": 4,
  "total": 835
}

Note: the field is now named response and not responses

Also, with release 5.2.1 as fix for issue #34, fields count and statusCount were added to the summary. These are also lost if the formatting option --json is used.

@AnWeber
Copy link
Contributor

AnWeber commented Jun 10, 2023

@dinurp Actually, it already works as it is designed. The idea of repeat is to quickly send several requests at the same time and thus put the server under load. These are not treated as own requests, but are merged at the end in the body of the first request. In the JSON output, I output the body only as a string and these contain the timings that you are interested in. For this reason it would be better for you to simply use `--output body' here.

I noticed that the timings are not properly merged in the '--json' output . The root element contains only the first timings object. I change this and output the average. And additionally I make it possible that the timings are also output when using --output exchange or --output timings.

@AnWeber AnWeber closed this as completed Jun 10, 2023
@dinurp
Copy link
Contributor Author

dinurp commented Jun 11, 2023

Thanks for pointing me to the right direction. I see that I can get what I was looking for by parsing the body.

httpyac send post.http -n post--repeat 25 --json  > out.json
jq "[.requests[].response.body|fromjson|.responses[]|{statusCode,timings}]" out.json

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

No branches or pull requests

2 participants