Correct way to handle errors from net.http?

112 views
Skip to first unread message

Rio

unread,
Feb 5, 2020, 5:54:59 AM2/5/20
to golang-nuts
Background: I was writing an HTTP proxy using net.http which supports both HTTP/1 and HTTP/2. I need to detect errors and do correct things according to RFC (https://http2.github.io/http2-spec/#CONNECT). 

It turns out that net.http has its own bundled copy of x/net/http2 (https://golang.org/src/net/http/h2_bundle.go) with nothing exported. So I cannot do things like

    var h2err http2.StreamError
    if errors.As(err, &h2err) { // dealing with errors

it will never match because the actual error is `http.http2StreamError` which is not exported. In this case, what's the correct way to detect http2 specific errors?
Reply all
Reply to author
Forward
0 new messages