Read-to-EOF is one of several conditions for connection reuse:
- Was the response body fully read (to EOF)?
- Does the server support HTTP keep-alives?
- Is DisableKeepAlives set to false (the default) on the http.Transport that
the client uses?
A connection will only be reused if all of these a
On Mon, Nov 25, 2019, 10:32 AM Andy Balholm wrote:
>
>
> > On Nov 25, 2019, at 9:54 AM, Liam wrote:
> >
> > - does the read-to-EOF stipulation also apply to Client.Get/Post() ?
>
> Yes. Those methods are fairly simple wrappers around Do.
>
> > - why does Response.Body.Close() before io.EOF not r
> On Nov 25, 2019, at 9:54 AM, Liam wrote:
>
> - does the read-to-EOF stipulation also apply to Client.Get/Post() ?
Yes. Those methods are fairly simple wrappers around Do.
> - why does Response.Body.Close() before io.EOF not release unread buffers or
> otherwise prepare it for persistence?
Scenario:
Sending a client request and only reading the whole Response.Body for
certain .StatusCode values, and/or reading only the first N bytes.
Docs for Client.Do()
"If the Body is not both read to EOF and closed, the Client's underlying
RoundTripper (typically Transport) may not be able to r