On Sat, Aug 2, 2014 at 12:10 PM, Camilo Aguilar <
camilo....@gmail.com> wrote:
>
> That makes no sense to me, would you please elaborate more? If I'm setting a timeout in the http.Client, as a user, I'm expecting it to kick in if the connection is unable to be established for some reason, ie: DNS taking too long to resolve or server taking to long to accept the connection. I wouldn't expect it to kick in in the middle of a data transfer.
The http client documentation is pretty clear with "and will interrupt reading of the Response.Body."
// Timeout specifies a time limit for requests made by this
// Client. The timeout includes connection time, any
// redirects, and reading the response body. The timer remains
// running after Get, Head, Post, or Do return and will
// interrupt reading of the Response.Body.
As is net.Conn
// A deadline is an absolute time after which I/O operations
// fail with a timeout (see type Error) instead of
// blocking. The deadline applies to all future I/O, not just
// the immediately following call to Read or Write.
The proper way to implement an idle timeout is to walk a deadline forward on each read or write operation. If you're looking for an IdleTimeout, you need to create your own net.Conn which sets deadlines on each operation. You can look at how we implemented the ReadWriteTimeout in
github.com/mreiferson/go-httpclient (which is mostly surpassed by go1.3 except for this situation).