• Brad Fitzpatrick's avatar
    net/http: read as much as possible (including EOF) during chunked reads · ff29be14
    Brad Fitzpatrick authored
    This is the chunked half of https://golang.org/cl/49570044 .
    
    We want full reads to return EOF as early as possible, when we
    know we're at the end, so http.Transport client connections are eagerly
    re-used in the common case, even if no Read or Close follows.
    
    To do this, make the chunkedReader.Read fill up its argument p []byte
    buffer as much as possible, as long as that doesn't involve doing
    any more blocking reads to read chunk headers. That means if we
    have a chunk EOF ("0\r\n") sitting in the incoming bufio.Reader,
    we see it and set EOF on our final Read.
    
    LGTM=adg
    R=adg
    CC=golang-codereviews
    https://golang.org/cl/58240043
    ff29be14
chunked_test.go 4.04 KB