Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Aug 30, 2022
1 parent d440d19 commit c3d0e2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/net/http/httputil/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
outreq.Header.Set("User-Agent", "")
}

var headerSet bool
trace := &httptrace.ClientTrace{
Got1xxResponse: func(code int, header textproto.MIMEHeader) error {
h := rw.Header()
Expand All @@ -462,7 +461,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {

// Clear headers, it's not automatically done by ResponseWriter.WriteHeader() for 1xx responses
for k, _ := range h {
h.Del(k)
delete(h, k)
}

return nil
Expand Down Expand Up @@ -490,15 +489,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if !p.modifyResponse(rw, res, outreq) {
return
}

h := rw.Header()
if headerSet {
for k, _ := range h {
h.Del(k)
}
}

copyHeader(h, res.Header)
copyHeader(rw.Header(), res.Header)

// The "Trailer" header isn't included in the Transport's response,
// at least for *http.Transport. Build it up from Trailer.
Expand Down
6 changes: 6 additions & 0 deletions src/net/http/httputil/reverseproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,12 @@ func Test1xxResponses(t *testing.T) {
}

for i := range expected {
if i >= len(got) {
t.Errorf("Expected %q link header; got nothing", expected[i])

continue
}

if expected[i] != got[i] {
t.Errorf("Expected %q link header; got %q", expected[i], got[i])
}
Expand Down

0 comments on commit c3d0e2a

Please sign in to comment.