mirror of
https://github.com/golang/go
synced 2024-11-22 14:54:46 -07:00
net/http: expose "http: server gave HTTP response to HTTPS client" error
Expose "http: server gave HTTP response to HTTPS client" error as `ErrSchemeMismatch`, so that it can be compared with `errors.Is` .
Fixes #44855
Change-Id: If96e0d000fdef641fea407310faf9e1c4f7ad0f0
GitHub-Last-Rev: 22879fc883
GitHub-Pull-Request: golang/go#50939
Reviewed-on: https://go-review.googlesource.com/c/go/+/382117
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
6a97a60b4b
commit
97df9c0b05
1
api/next/44855.txt
Normal file
1
api/next/44855.txt
Normal file
@ -0,0 +1 @@
|
||||
pkg net/http, var ErrSchemeMismatch error #44855
|
@ -204,6 +204,9 @@ func (c *Client) transport() RoundTripper {
|
||||
return DefaultTransport
|
||||
}
|
||||
|
||||
// ErrSchemeMismatch is returned when a server returns an HTTP response to an HTTPS client.
|
||||
var ErrSchemeMismatch = errors.New("http: server gave HTTP response to HTTPS client")
|
||||
|
||||
// send issues an HTTP request.
|
||||
// Caller should close resp.Body when done reading from it.
|
||||
func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, didTimeout func() bool, err error) {
|
||||
@ -265,7 +268,7 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d
|
||||
// response looks like HTTP and give a more helpful error.
|
||||
// See golang.org/issue/11111.
|
||||
if string(tlsErr.RecordHeader[:]) == "HTTP/" {
|
||||
err = errors.New("http: server gave HTTP response to HTTPS client")
|
||||
err = ErrSchemeMismatch
|
||||
}
|
||||
}
|
||||
return nil, didTimeout, err
|
||||
|
Loading…
Reference in New Issue
Block a user