• Brad Fitzpatrick's avatar
    net/http: reuse client connections earlier when Content-Length is set · 01e3b4fc
    Brad Fitzpatrick authored
    Set EOF on the final Read of a body with a Content-Length, which
    will cause clients to recycle their connection immediately upon
    the final Read, rather than waiting for another Read or Close
    (neither of which might come).  This happens often when client
    code is simply something like:
    
      err := json.NewDecoder(resp.Body).Decode(&dest)
      ...
    
    Then there's usually no subsequent Read. Even if the client
    calls Close (which they should): in Go 1.1, the body was
    slurped to EOF, but in Go 1.2, that was then treated as a
    Close-before-EOF and the underlying connection was closed.
    But that's assuming the user even calls Close. Many don't.
    Reading to EOF also causes a connection be reused. Now the EOF
    arrives earlier.
    
    This CL only addresses the Content-Length case. A future CL
    will address the chunked case.
    
    LGTM=adg
    R=adg
    CC=golang-codereviews
    https://golang.org/cl/49570044
    01e3b4fc
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...