vegeta
vegeta copied to clipboard
Proposal: Use content-length header instead of body for bytes in
Proposal
Use response.ContentLength
in determining the number bytes in of a response rather then len(response.Body)
Background
I noticed that my bytes in was zero if I set the body limit to 0. I don't want to read in the body but I do want to know the size of it.
To preserve previous behaviour we could do this only if MaxBody
is set.
Workarounds
Don't use the MaxBody
option
This would not work if the server sends data in chunked encoding, but in that case, it should be set to -1
as per documentation:
// ContentLength records the length of the associated content. The
// value -1 indicates that the length is unknown. Unless Request.Method
// is "HEAD", values >= 0 indicate that the given number of bytes may
// be read from Body.
ContentLength int64
PR welcome.
Great thanks, PR #384 ready for review