Skip to content

net/http/cgi: QUERY_STRING not used when REQUEST_URI is set (Tomcat) #54961

Description

@TamyGit

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

$ go version
go version go1.19.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

Compile on Debian GNU/Linux 11 (bullseye) with Intel CPU
Run on Raspbian GNU/Linux 10 (buster) with Armv7 (Raspberry Pi 3 Model B)

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build3827448816=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I created a CGI program which parse GET Parameters with net/http#Request.ParseForm.
On Apache, that works.
On Tomcat, it doesn't.
The reason is a environment variable "REQUEST_URI" doesn't include parameters on Tomcat, I guess.

Environment variables:

[Apache]
REQUEST_URI="/cgi-bin/testcgi?id=1"
QUERY_STRING="id=1"

[Tomcat]
REQUEST_URI="/cgi-bin/testcgi"
QUERY_STRING="id=1"

I checked the source code of this problem. (net/http/cgi/child.go)
QUERY_STRING is used only when REQUEST_URI is blank. (Am I right?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions