Skip to content

net/http: context isn't canceled on client disconnection #20668

Closed
@utrack

Description

@utrack

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

go version go1.7.4 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/u/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build348831087=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

Arch Linux

What did you do?

Stumbled upon it on failing tests. Here's a snippet:
https://play.golang.org/p/v4ij4Elrqa

What did you expect to see?

Get http://127.0.0.1:2/: context deadline exceeded
true

Works like this on latest (go 1.8.*)

What did you see instead?

Get http://127.0.0.1:44773/: net/http: request canceled
false

This test is kinda hacky b/c .Shutdown() and .Close() aren't there on Go 1.7.
The point is: r.Context() is never canceled on server's side once client disconnects.

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