Capture BodyTextLength

This commit is contained in:
Tim Schumacher 2020-09-17 15:01:27 -04:00
förälder a7ad9a27d2
incheckning fc82b6b673
2 ändrade filer med 4 tillägg och 1 borttagningar

Visa fil

@ -63,6 +63,8 @@ type Response struct {
// BodyHash is the hash digest hex of the decoded http body, formatted `<kind>:<hex>`
// e.g. `sha256:deadbeef100020003000400050006000700080009000a000b000c000d000e000`
BodyHash string `json:"body_hash,omitempty"`
// Number of bytes read from the server and encoded into BodyText
BodyTextLength int64 `json:"body_length,omitempty"`
// ContentLength records the length of the associated content. The
// value -1 indicates that the length is unknown. Unless Request.Method

Visa fil

@ -415,7 +415,8 @@ func (scan *scan) Grab() *zgrab2.ScanError {
if resp.ContentLength >= 0 && resp.ContentLength < maxReadLen {
readLen = resp.ContentLength
}
io.CopyN(buf, resp.Body, readLen)
// EOF ignored here because that's the way it was, CopyN goes up to readLen bytes
scan.results.Response.BodyTextLength, _ = io.CopyN(buf, resp.Body, readLen)
bufAsString := buf.String()
// do best effort attempt to determine the response's encoding