Skip to content

net/http: Response doesn't contain Connection header when Keep-Alive #15784

Closed
@AlmogBaku

Description

@AlmogBaku

When sending a request with Keep-Alive, go respond with an HTTP response that is not contains the Connection header, although the connection maintained.


  1. What version of Go are you using (go version)?
go version go1.6 darwin/amd64
  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="<my_path>"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
  1. What did you do?
  • Start a basic HTTP server
  • Open a telnet connection to it, and send a Keep-Alive request
  • Send immediately another request to see if the connection maintained
$ telnet localhost 8000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
Host: localhost
Connection: Keep-Alive

HTTP/1.1 200 OK
Date: Sat, 21 May 2016 11:59:42 GMT
Content-Length: 12
Content-Type: text/plain; charset=utf-8

Hello world!GET / HTTP/1.1
Host: localhost
Connection: Keep-Alive

HTTP/1.1 200 OK
Date: Sat, 21 May 2016 11:59:47 GMT
Content-Length: 12
Content-Type: text/plain; charset=utf-8

Hello world!
  1. What did you expect to see?
    Connection header should be maintained when the keep-alive maintained. as specified [in the RFC](https://www.w3.org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-01#Persistent Connections):

    The Connection header field with a keep-alive keyword must be sent on all requests and responses that wish to continue the persistence.

  2. What did you see instead?
    Connection header were dropped.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions