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: client crash with custom RoundTrip #15577

rsc opened this issue May 6, 2016 · 0 comments

net/http: client crash with custom RoundTrip #15577

rsc opened this issue May 6, 2016 · 0 comments


Copy link

@rsc rsc commented May 6, 2016

This program worked in Go 1.6 and earlier but crashes with Go 1.7.

goroutine 1 [running]:
panic(0x1d1440, 0xc82000c160)
    /Users/rsc/go/src/runtime/panic.go:500 +0x18c
net/http.(*Client).doFollowingRedirects.func1(0x2e8680, 0xc82000d0e0, 0xc82002e030, 0x1)
    /Users/rsc/go/src/net/http/client.go:446 +0x93
net/http.(*Client).doFollowingRedirects(0x2fdc00, 0xc8200d20f0, 0x226478, 0xf, 0x0, 0x0)
    /Users/rsc/go/src/net/http/client.go:489 +0x8ad
net/http.(*Client).Get(0x2fdc00, 0x20de9c, 0xf, 0x23b9, 0x1d5140, 0xc8200001a0)
    /Users/rsc/go/src/net/http/client.go:415 +0x89
    /tmp/x.go:27 +0x38
package main

import (

var client = &http.Client{
    CheckRedirect: func(*http.Request, []*http.Request) error { return fmt.Errorf("no redirects!") },
    Transport:     new(tripper),

type tripper struct{}

func (tripper) RoundTrip(*http.Request) (*http.Response, error) {
    resp := &http.Response{
        StatusCode: 303,
        Header:     map[string][]string{"Location": {""}},
        Body:       ioutil.NopCloser(strings.NewReader("")),
    return resp, nil

func main() {
@rsc rsc added this to the Go1.7 milestone May 6, 2016
@gopherbot gopherbot closed this in 31283dd May 6, 2016
@golang golang locked and limited conversation to collaborators May 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.