We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
$ gotip version go version devel go1.20-9f0f87c806 Tue Aug 23 06:11:32 2022 +0000 darwin/amd64
Yes.
go env
$ gotip env GO111MODULE="on" GOARCH="amd64" GOBIN="/Users/.../bin" GOCACHE="/Users/.../Library/Caches/go-build" GOENV="/Users/.../Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/.../pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/..." GOPRIVATE="REDACTED" GOPROXY="https://proxy.golang.org,direct" GOROOT="/Users/.../sdk/gotip" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/.../sdk/gotip/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="devel go1.20-9f0f87c806 Tue Aug 23 06:11:32 2022 +0000" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="0" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/b6/ycbtfvh11373tq5d7mpvmg_h0000gn/T/go-build1281822184=/tmp/go-build -gno-record-gcc-switches -fno-common"
Send a simple HTTP GET request using curl to a Go's HTTP server and dump it using httputil.DumpRequest. The server code:
curl
httputil.DumpRequest
package main import ( "fmt" "io" "log" "net/http" "net/http/httputil" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { b, _ := httputil.DumpRequest(r, true) fmt.Printf("%s\n", b) w.WriteHeader(http.StatusOK) io.WriteString(w, "OK") }) if err := http.ListenAndServe("127.0.0.1:10000", nil); err != nil { log.Fatalf("failed to listen: %v", err) } }
The curl command:
$ curl -i http://127.0.0.1:10000/ -H 'Connection: close'
Go server printing the same request I see in Wireshark.
Go's httputil.DumpRequest duplicating the Connection header.
Connection
$ gotip run . GET / HTTP/1.1 Host: 127.0.0.1:10000 Connection: close Accept: */* Connection: close User-Agent: curl/7.79.1
While this is what Wireshark sees (Follow TCP stream view):
GET / HTTP/1.1 Host: 127.0.0.1:10000 User-Agent: curl/7.79.1 Accept: */* Connection: close HTTP/1.1 200 OK Date: Tue, 23 Aug 2022 08:59:42 GMT Content-Length: 2 Content-Type: text/plain; charset=utf-8 Connection: close OK
The issue seems to come from https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/net/http/httputil/dump.go;l=261-263. I'd be happy to contribute a CL and a test fixing this behavior.
The text was updated successfully, but these errors were encountered:
feel free to send a fix + tests
Sorry, something went wrong.
Change https://go.dev/cl/425155 mentions this issue: net/http/httputil: do not duplicate 'Connection: close' headers
net/http/httputil: do not duplicate 'Connection: close' headers
44d057d
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Send a simple HTTP GET request using
curl
to a Go's HTTP server and dump it usinghttputil.DumpRequest
. The server code:The
curl
command:$ curl -i http://127.0.0.1:10000/ -H 'Connection: close'
What did you expect to see?
Go server printing the same request I see in Wireshark.
What did you see instead?
Go's
httputil.DumpRequest
duplicating theConnection
header.While this is what Wireshark sees (Follow TCP stream view):
The issue seems to come from https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/net/http/httputil/dump.go;l=261-263. I'd be happy to contribute a CL and a test fixing this behavior.
The text was updated successfully, but these errors were encountered: