Go version
go version go1.24.6 linux/amd64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v3'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/username/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/username/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1109156415=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/mnt/BigSSD/go/src/git.mstar.dev/mstar/fragment-bug/go.mod'
GOMODCACHE='/home/username/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/username/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/username/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.6'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
I am currently implementing a server to interact with Twitch's API. This includes reading a bearer token from the callback-url's fragment. The problem is that the net/http
default server does not parse fragments correctly and the request url's fragment value is empty. Parsing the same url with net/url
gives the proper fragment.
Sample program: [https://go.dev/play/p/8__P4p43Puy]
What did you see happen?
The url provided in the request for the handler does not read the fragment and returns an empty string.
Meanwhile net/url
parses the same url correctly and returns the expected fragment.
What did you expect to see?
Both net/http
and net/url
to return the same url and fragment
Comment From: seankhliao
I believe this is an invalid test as by spec, fragments aren't sent in http requests.
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