-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
Description
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
main.main()
/tmp/x.go:27 +0x38
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
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": {"http://www.example.com/"}},
Body: ioutil.NopCloser(strings.NewReader("")),
}
return resp, nil
}
func main() {
client.Get("http://foo.com/")
}