Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/url: unsupported protocol scheme in header field #56027

Closed
jnelle opened this issue Oct 4, 2022 · 4 comments
Closed

net/url: unsupported protocol scheme in header field #56027

jnelle opened this issue Oct 4, 2022 · 4 comments

Comments

@jnelle
Copy link

jnelle commented Oct 4, 2022

What version of Go are you using (go version)?

$ go 1.19.1

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jimbo/.cache/go-build"
GOENV="/home/jimbo/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jimbo/go/pkg/mod"
GOOS="linux"
GOPATH="/home/jimbo/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/shared/dev/myfitnesspal/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build714340508=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I wrote a http wrapper for the MyFitnessPal API. When I'm trying to get a callback code which is located in the header, I'll get an error message. To reproduce clone the following repository and install the dependencies and then run:

go run main.go

What did you expect to see?

A response with status code 302 and a location header which contains the callback code.

What did you see instead?

I'll get the following error message:

net/url.Error {Op: "Post", URL: "mfp://identity/callback?code=XXXX", Err: error(*errors.errorString) *{s: "http2: unsupported scheme"}}

response variable is nil.

Screenshot 2022-10-04 130932

I know that this "mfp://" url is in headers, because I checked it with a proxy before (see screenshot below)

Screenshot 2022-10-04 130532

It looks like net/http is validating header values, which, if I understood it right, should'nt do it

@ZekeLu
Copy link
Contributor

ZekeLu commented Oct 4, 2022

If the http client follows the redirect, it will see mfp://identify/.... which is invalid to the http client. I think you want to configure CheckRedirect of the http client to prevent it from following the redirect and handle the header yourself. See https://pkg.go.dev/net/http@go1.19.1#Client for documentation about CheckRedirect.

@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2022
@jnelle
Copy link
Author

jnelle commented Oct 4, 2022

Why isn't this a bug? @seankhliao

@seankhliao
Copy link
Member

The client followed the redirect (default policy) and you haven't registered a RoundTripper for the given scheme, so it's an outgoing request error.

@golang golang locked and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants