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

net/http: Response.Write adds redundant "Connection: Close" headers #19499

Closed
roglew opened this issue Mar 10, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@roglew
Copy link

commented Mar 10, 2017

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

go version go1.8 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/golang"
GORACE=""
GOROOT="/home/user/go"
GOTOOLDIR="/home/user/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build896761484=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

package main

import (
	"net/http"
	"bufio"
	"bytes"
	"os"
)

func main() {
	rspbytes := []byte("HTTP/1.0 200 OK\r\n\r\nAAAA")
	buf := bytes.NewBuffer(rspbytes)
	
	httpRsp, _ := http.ReadResponse(bufio.NewReader(buf), nil)
	buf2 := bytes.NewBuffer(make([]byte, 0))
	httpRsp.Write(buf2)
	
	httpRsp2, _ := http.ReadResponse(bufio.NewReader(buf2), nil)
	buf3 := bytes.NewBuffer(make([]byte, 0))
	httpRsp2.Write(buf3)
	
	httpRsp3, _ := http.ReadResponse(bufio.NewReader(buf3), nil)
	httpRsp3.Write(os.Stdout)
}

Playground Link

What did you expect to see?

HTTP/1.0 200 OK
Connection: close

AAAA

or

HTTP/1.0 200 OK

AAAA

What did you see instead?

HTTP/1.0 200 OK
Connection: close
Connection: close
Connection: close

AAAA

@josharian josharian changed the title http.Response.Write adds redundant "Connection: Close" headers net/http: Response.Write adds redundant "Connection: Close" headers Mar 10, 2017

@odeke-em

This comment has been minimized.

Copy link
Member

commented Mar 10, 2017

/cc @bradfitz

@gopherbot

This comment has been minimized.

Copy link

commented Mar 11, 2017

CL https://golang.org/cl/38076 mentions this issue.

@bradfitz bradfitz added this to the Go1.9 milestone Mar 21, 2017

@gopherbot gopherbot closed this in 5dbdd79 May 24, 2017

@golang golang locked and limited conversation to collaborators May 24, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.