You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Austin Pena\AppData\Local\go-build
set GOENV=C:\Users\Austin Pena\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Austin Pena\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
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
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\AUSTIN~1\AppData\Local\Temp\go-build661771174=/tmp/go-build -gno-record-gcc-switches
What did you do?
I was getting timeouts on Go Playground otherwise I would have posted it there.
Here's the code for reproducibility. Please try to access https://easy-dp.ngrok.io to see the issue.
Create a Reverse Proxy accessing Gzipped/ Br encoded Content
Request a publicly available URL, I just grabbed Google Analytics
Attempt to encode and decode the response via an http2 connection with a proxy.modifyresponse function
Watch as content is dropped.
However, this only occurs under the following conditions:
Under the normal http connection, there's no problem, but under the https connection the script may or may not print out to a certain length. Sometimes it doesn't print at all, sometimes it prints about 30%.
This is a cross browser issue.
The text was updated successfully, but these errors were encountered:
The Content-Length header indicates the size of the entity body in the message, in bytes. The size includes any content encodings (the Content-Length of a gzip-compressed text file will be the compressed size, not the original size).
@seankhliao Thanks for taking the time to point that out. I had originally done that, but failed to close the gzip writer correctly. I was having this issue until I rewrote my code to the following:
ifr.Header.Get("Content-Encoding") =="gzip" {
gzipReader, err:=gzip.NewReader(bytes.NewBuffer(bytesFromBody))
iferr!=nil {
returnnil
}
defergzipReader.Close()
readableBytes, err:=ioutil.ReadAll(gzipReader)
varb bytes.BuffergzipWriter, err:=gzip.NewWriterLevel(&b, gzip.DefaultCompression)
iferr!=nil {
returnnil
}
writtenLen, err:=gzipWriter.Write(readableBytes)
gzipWriter.Close() // This was the culprit. It needed to be closed herefmt.Println("Wrote ", writtenLen)
iferr!=nil {
returnnil
}
r.ContentLength=int64(b.Len())
r.Header.Set("Content-Length", strconv.FormatInt(int64(b.Len()), 10))
r.Body=ioutil.NopCloser(&b)
returnnil
}
It's interesting to me that it only happened over an H2C connection though. Perhaps it was just due to latency? Hard to say.
Uh oh!
There was an error while loading. Please reload this page.
What version of Go are you using (
1.153
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Output
$ go env
What did you do?
I was getting timeouts on Go Playground otherwise I would have posted it there.
Here's the code for reproducibility. Please try to access https://easy-dp.ngrok.io to see the issue.
However, this only occurs under the following conditions:
proxy.ModifyResponse
functionWhat did you expect to see?
I expect to see the ability to open the bytes, modify them, and update the response body on an H2C connection
What did you see instead?
Two things of note happen:
This is a cross browser issue.
The text was updated successfully, but these errors were encountered: