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: TimeoutHandler: 200 OK should be sent if not specified #15948

h12w opened this issue Jun 3, 2016 · 1 comment


None yet
5 participants
Copy link

commented Jun 3, 2016

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

1.6.2 and 1.4.3

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

linux, amd64

What did you do?

Minimal example server (main.go):

package main

import (

func main() {
    log.Fatal(http.ListenAndServe(":9999", http.TimeoutHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    }), time.Second, "timeout")))


go run main.go
curl -i ""

What did you expect to see?

I expect 200 OK because it is consistent with the default behavior without the TimeoutHandler.

HTTP/1.1 200 OK

What did you see instead?

HTTP/1.1 0 status code 0


In func (h *timeoutHandler) ServeHTTP in net/http/server.go, change the code from:



if tw.code == 0 {
    tw.code = StatusOK

@ianlancetaylor ianlancetaylor changed the title net/http.TimeoutHandler: 200 OK should be sent if not specified net/http: TimeoutHandler: 200 OK should be sent if not specified Jun 3, 2016

@ianlancetaylor ianlancetaylor added this to the Go1.8 milestone Jun 3, 2016

@adg adg assigned adg and unassigned bradfitz Jun 6, 2016


This comment has been minimized.

Copy link

commented Jun 6, 2016

CL mentions this issue.

@gopherbot gopherbot closed this in 3ba3155 Jun 6, 2016

@golang golang locked and limited conversation to collaborators Jun 6, 2017

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.