go: net/http: add ErrSchemeMismatch
What version of Go are you using (go version)?
$ go version go version go1.16 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you expect to see?
I’d like to see the http: server gave HTTP response to HTTPS client error in the net/http package to be exposed as a constant that can be compared with errors.Is
Context
I’m working on a clone of Docker called nerdctl (contaiNERD ctl).
I want to compare http: server gave HTTP response to HTTPS client with errors.Is, for ease of reimplementing dockerd --insecure-registries, which attempts HTTPS first and then falls back to HTTP.
What did you see instead?
The http: server gave HTTP response to HTTPS client error is not exposed.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (13 by maintainers)
Commits related to this issue
- 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... — committed to AkihiroSuda/go by AkihiroSuda 2 years ago
- 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... — committed to AkihiroSuda/go by AkihiroSuda 2 years ago
- 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... — committed to AkihiroSuda/go by AkihiroSuda 2 years ago
- doc: fill out net/http.ErrSchemeMismatch note For #44855 Change-Id: I517394b227ea948ed3e1f9ffdaab2bb2676863c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/496795 TryBot-Bypass: Dmitri Shur... — committed to golang/go by danp a year ago
- refactor: use ErrSchemeMismatch and ECONNREFUSED ref: https://github.com/golang/go/issues/44855 Signed-off-by: Yadong Ding <ding_yadong@foxmail.com> — committed to Desiki-high/nydus by Desiki-high 6 months ago
- refactor: use ErrSchemeMismatch and ECONNREFUSED ref: https://github.com/golang/go/issues/44855 Signed-off-by: Yadong Ding <ding_yadong@foxmail.com> — committed to Desiki-high/nydus by Desiki-high 6 months ago
- refactor: use ErrSchemeMismatch and ECONNREFUSED ref: https://github.com/golang/go/issues/44855 Signed-off-by: Yadong Ding <ding_yadong@foxmail.com> — committed to dragonflyoss/nydus by Desiki-high 6 months ago
- refactor: use ErrSchemeMismatch and ECONNREFUSED ref: https://github.com/golang/go/issues/44855 Signed-off-by: Yadong Ding <ding_yadong@foxmail.com> — committed to Desiki-high/nydus by Desiki-high 6 months ago
This is a proposed API change, so adding to the proposal process.
Specific proposal:
Add
http.ErrSchemeMismatch, a distinguishable error that indicates an HTTPS server received what looks like an HTTP request. This converts an existing error to an exported, distinguishable symbol. See https://go.dev/cl/382117.I’m fine with (2). Or (1) if we name it, say,
ErrSchemeMismatch(“HTTP” in “ErrHTTPResponse” sounds too generic, as “HTTP” often also means “HTTPS”).I wouldn’t want to see a new function. That’s too heavy in godoc for how fringe this is.