Skip to content

Commit 55e01f3

Browse files
committed
Should not set transfer-encoding header for 204 response according to http specs
1 parent 20f7705 commit 55e01f3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

examples/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
module github.com/elazarl/goproxy/examples/goproxy-transparent
22

3+
go 1.22.5
4+
35
require (
46
github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a
57
github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b
68
)
79

10+
require (
11+
github.com/SpectoLabs/goproxy/ext v0.0.0-20220724222243-c982a2c966ae // indirect
12+
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4 // indirect
13+
)
14+
815
replace github.com/elazarl/goproxy => ../

examples/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
github.com/SpectoLabs/goproxy/ext v0.0.0-20220724222243-c982a2c966ae/go.mod h1:rnDN1CpKP9iJXwxRtnvM7d5wdPHQY0K5NkHeXWPlQ+o=
12
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
23
github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b h1:IpLPmn6Re21F0MaV6Zsc5RdSE6KuoFpWmHiUSEs3PrE=
34
github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b/go.mod h1:aA6DnFhALT3zH0y+A39we+zbrdMC2N0X/q21e6FI0LU=

https.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
267267
return
268268
}
269269

270-
if resp.Request.Method == "HEAD" {
270+
if resp.Request.Method == "HEAD" || resp.StatusCode == 204 {
271271
// don't change Content-Length for HEAD request
272272
} else {
273273
// Since we don't know the length of resp, return chunked encoded response
@@ -286,7 +286,7 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
286286
return
287287
}
288288

289-
if resp.Request.Method == "HEAD" {
289+
if resp.Request.Method == "HEAD" || resp.StatusCode == 204 {
290290
// Don't write out a response body for HEAD request
291291
} else {
292292
chunked := newChunkedWriter(rawClientTls)

0 commit comments

Comments
 (0)