• Brad Fitzpatrick's avatar
    http: fix transport bug with zero-length bodies · ca83cd2c
    Brad Fitzpatrick authored
    An optimization in Transport which re-uses TCP
    connections early in the case where there is
    no response body interacted poorly with
    ErrBodyReadAfterClose.  Upon recycling the TCP
    connection early we would Close the Response.Body
    (in case the user forgot to), but in the case
    of a zero-lengthed body, the user's handler might
    not have run yet.
    
    This CL makes sure the Transport doesn't try
    to Close requests when we're about to immediately
    re-use the TCP connection.
    
    This also includes additional tests I wrote
    while debugging.
    
    R=rsc, bradfitzgoog
    CC=golang-dev
    https://golang.org/cl/4529050
    ca83cd2c
serve_test.go 19.8 KB