• Jed Denlea's avatar
    net/http: close server conn after request body error · c2db5f4c
    Jed Denlea authored
    HTTP servers attempt to entirely consume a request body before sending a
    response.  However, when doing so, it previously would ignore any errors
    encountered.
    
    Unfortunately, the errors triggered at this stage are indicative of at
    least a couple problems: read timeouts and chunked encoding errors.
    This means properly crafted and/or timed requests could lead to a
    "smuggled" request.
    
    The fix is to inspect the errors created by the response body Reader,
    and treat anything other than io.EOF or ErrBodyReadAfterClose as
    fatal to the connection.
    
    Fixes #11930
    
    Change-Id: I0bf18006d7d8f6537529823fc450f2e2bdb7c18e
    Reviewed-on: https://go-review.googlesource.com/12865Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    c2db5f4c
serve_test.go 94.6 KB