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: setting Opaque ignores Host value on String #20421

Closed
vanbroup opened this issue May 19, 2017 · 3 comments
Closed

net/url: setting Opaque ignores Host value on String #20421

vanbroup opened this issue May 19, 2017 · 3 comments

Comments

@vanbroup
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

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

go1.8.1 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/gopkg"
GORACE=""
GOROOT="/opt/go"
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

https://play.golang.org/p/WWaneBpjNX

What did you expect to see?

http://ocsp.int-x3.letsencrypt.org/opaque-set-in-url

What did you see instead?

http:/opaque-set-in-url

@fraenkel
Copy link
Contributor

Just curious why you think it should be displayed that way?
The docs for URL are pretty clear that opaque do not start with / and comes right after the scheme.
What you are expecting is the general form + path.

@vanbroup
Copy link
Contributor Author

You are correct that the documentation clearly states that the host is not part of the opaque. I should have given some more background information when creating this issue.

I thought the behavior was incorrect because when you include the host part in the Opaque your HTTP request would result in a different request (not necessarily invalid) than when the Opaque would not be set.

Using the http.Request.URL value returns unexpected results.

Example:
https://play.golang.org/p/CMUTLohe-V

No Opaque:

GET /opaque-set-in-url HTTP/0.0
Host: example.com

With host duplicated in Opaque:

GET http://example.com/opaque-set-in-url HTTP/0.0
Host: example.com

But according to rfc3986:

everything after the scheme component delimiter (":") is considered opaque to URI processing

So according to the name 'opaque' it's not invalid but it leads to unexpected results for regular use cases.

Unfortunately, it was required to use url.URL with Opaque when the URL contains any special encoding, especially base64 which could include an encoded / (%2F) where the encoding will be removed and threaded as a directory.

But when I just tested this it doesn't look to be a problem anymore, so or I got confused about what character caused the problem or it was resolved in a go release since I wrote this code a couple of years back...

I will try to dive into my archives and try to replicate the original issue that forced us to use Opaque.

@vanbroup
Copy link
Contributor Author

The fix using Opaque was implemented about two years ago. Just verified with tcpdump and the original problem looks to be resolved in the current go version.

@golang golang locked and limited conversation to collaborators May 23, 2018
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

3 participants