mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00: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 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
4f4a9c7fff
commit
22879fc883
2 changed files with 5 additions and 1 deletions
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 a new issue