Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/http2: unexpected custom errors when HTTP2.0 PUT request gets lesser content than the specified content-length #30648

Closed
harshavardhana opened this issue Mar 7, 2019 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@harshavardhana
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version go1.12 linux/amd64

Does this issue reproduce with the latest release?

Yes with go1.12

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/harsha/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/harsha/mygo"
GOPROXY=""
GORACE=""
GOROOT="/home/harsha/.gimme/versions/go1.12.linux.amd64"
GOTMPDIR=""
GOTOOLDIR="/home/harsha/.gimme/versions/go1.12.linux.amd64/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build150613686=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Set a high content-length and send shorter data leads to unexpected errors reported by the server

// endStream closes a Request.Body's pipe. It is called when a DATA
// frame says a request body is over (or after trailers).
func (st *http2stream) endStream() {
        sc := st.sc
        sc.serveG.check()

        if st.declBodyBytes != -1 && st.declBodyBytes != st.bodyBytes {
                st.body.CloseWithError(fmt.Errorf("request declared a Content-Length of %d but only wrote %d bytes",
                        st.declBodyBytes, st.bodyBytes))
        } else {
                st.body.closeWithErrorAndCode(io.EOF, st.copyTrailersToHandlerRequest)
                st.body.CloseWithError(io.EOF)
        }
        st.state = http2stateHalfClosedRemote
}

Should be ideally

// endStream closes a Request.Body's pipe. It is called when a DATA
// frame says a request body is over (or after trailers).
func (st *http2stream) endStream() {
        sc := st.sc
        sc.serveG.check()

        if st.declBodyBytes != -1 && st.declBodyBytes != st.bodyBytes {
                st.body.CloseWithError(io.ErrUnexpectedEOF)
        } else {
                st.body.closeWithErrorAndCode(io.EOF, st.copyTrailersToHandlerRequest)
                st.body.CloseWithError(io.EOF)
        }
        st.state = http2stateHalfClosedRemote
}

What did you expect to see?

Expected to see io.ErrUnexpectedEOF

What did you see instead?

request declared a Content-Length of %d but only wrote %d bytes

This behavior differs from HTTP 1.1 behavior.

harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
@agnivade agnivade changed the title Uexpected custom errors when HTTP2.0 PUT request gets lesser content than the specified content-length x/net/http2: uexpected custom errors when HTTP2.0 PUT request gets lesser content than the specified content-length Mar 7, 2019
@agnivade agnivade changed the title x/net/http2: uexpected custom errors when HTTP2.0 PUT request gets lesser content than the specified content-length x/net/http2: unexpected custom errors when HTTP2.0 PUT request gets lesser content than the specified content-length Mar 7, 2019
@agnivade
Copy link
Contributor

agnivade commented Mar 7, 2019

/cc @bradfitz @fraenkel

@fraenkel
Copy link
Contributor

fraenkel commented Mar 7, 2019

An example would help.
The http path has something similar, https://github.com/golang/go/blob/master/src/net/http/transfer.go#L387

harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
@harshavardhana
Copy link
Contributor Author

will do @fraenkel

harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
harshavardhana added a commit to harshavardhana/minio that referenced this issue Mar 7, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
harshavardhana added a commit to minio/minio that referenced this issue Mar 8, 2019
We should internally handle when http2 input stream has smaller
content than its content-length header

Upstream issue reported golang/go#30648

This a change which we need to handle internally until Go fixes it
correctly, till now our code doesn't expect a custom error to be returned.
@julieqiu julieqiu added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 11, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants