• Brad Fitzpatrick's avatar
    net/http: fix race in TimeoutHandler · 0478f7b9
    Brad Fitzpatrick authored
    New implementation of TimeoutHandler: buffer everything to memory.
    
    All or nothing: either the handler finishes completely within the
    timeout (in which case the wrapper writes it all), or it misses the
    timeout and none of it gets written, in which case handler wrapper can
    reliably print the error response without fear that some of the
    wrapped Handler's code already wrote to the output.
    
    Now the goroutine running the wrapped Handler has its own write buffer
    and Header copy.
    
    Document the limitations.
    
    Fixes #9162
    
    Change-Id: Ia058c1d62cefd11843e7a2fc1ae1609d75de2441
    Reviewed-on: https://go-review.googlesource.com/17752Reviewed-by: 's avatarDavid Symonds <dsymonds@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    0478f7b9
server.go 67.9 KB