Skip to content

net/http, net/http/httputil: Chunked reader doesn't read the final two bytes of the chunked data #4390

Closed
@gopherbot

Description

@gopherbot

by jgrahamc:

What is the expected output?

It's expected that the function beginChunk() will read the trailing CRLF from the final
chunk size when doing chunked encoding. It does not. The function is as follows:

func (cr *chunkedReader) beginChunk() {
    // chunk-size CRLF
    var line string
    line, cr.err = readLine(cr.r)
    if cr.err != nil {
        return
    }
    cr.n, cr.err = strconv.ParseUint(line, 16, 64)
    if cr.err != nil {
        return
    }
    if cr.n == 0 {
        cr.err = io.EOF
    }
}

When cr.n == 0 the readLine() has consumed 0\r\n but there's an additional \r\n at the
end (see RFC2616 section 3.6).

What do you see instead?

There are two bytes left in the buffer when done.

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

64 bit Linux

Which version are you using?  (run 'go version')

go version go1.0.3

Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions