Skip to content

Response body not always fully read #176

@eitankatznelson

Description

@eitankatznelson

The http.Do function documentation states that:

// If the returned error is nil, the Response will contain a non-nil
// Body which the user is expected to close. If the Body is not both
// read to EOF and closed, the Client's underlying RoundTripper
// (typically Transport) may not be able to re-use a persistent TCP
// connection to the server for a subsequent "keep-alive" request.

In the report method, if the response code is <300 the client doesn't read the response body causing connections to get closed by servers.

Simple fix would be to add the line:
ioutil.ReadAll(res.Body)
in the condition block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions