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

affected/package: http #59759

Closed
js10x opened this issue Apr 21, 2023 · 2 comments
Closed

affected/package: http #59759

js10x opened this issue Apr 21, 2023 · 2 comments

Comments

@js10x
Copy link

js10x commented Apr 21, 2023

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

1.20.3, but it's reproducible in earlier versions.

$ go version

Does this issue reproduce with the latest release?

Yes.

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

Windows AMD64

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=`omitted`
set GOCACHE=`omitted`
set GOENV=`omitted`
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=`omitted`
set GONOPROXY=`omitted`
set GONOSUMDB=`omitted`
set GOOS=windows
set GOPATH=`omitted`
set GOPRIVATE=`omitted`
set GOPROXY=`omitted`
set GOROOT=`omitted`
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=`omitted`
set GOVCS=
set GOVERSION=go1.20.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=`omitted`
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

When consuming http.NewRequest(..), I passed the word "pancakes" to the NewRequest method parameter.

What did you expect to see?

I'd expect to see an error returned when passing an invalid method as the httpMethod parameter to the function.

req, err := http.NewRequest("pancakes", "some-url", nil)
err should NOT be nil with the above usage. Seems to be a bug in the Go source here:
https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/net/http/request.go;l=835

What did you see instead?

Error is not returned by the function, instead it marks the request as valid.

@seankhliao
Copy link
Member

As the comments there note, http may be extended with other methods. The standard library should not block them.

Working as intended.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2023
@js10x
Copy link
Author

js10x commented Apr 22, 2023

Ok I see, dug a little further down, my mistake. Apologies. So I need to use a Unicode character to get it to return an error:
method := "◑"

@golang golang locked and limited conversation to collaborators Apr 21, 2024
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