PDGGK opened a new pull request, #1083:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1083

   **What this PR does**:
   
   When an upstream sends a header more than once, Pixiu passes only the first 
value on to the client. A backend that sets two cookies in one response (a 
session cookie and a CSRF cookie, for example) loses the second one at the 
gateway, so the browser never receives it. `Vary`, `Link` and any other 
repeated header get cut down the same way.
   
   I ran the config from `docs/sample/http/http-http.md` (minus the 
`dgp.filter.http.response` filter, which no longer exists) with 
`dgp.filter.http.httpproxy` in front of a small Go backend that answers with 
two `Set-Cookie` and two `Vary` headers. Calling the backend directly returns 
both values of each. Through Pixiu on `develop` (10371007), the client gets 
only `Set-Cookie: a=1; Path=/` and `Vary: Accept-Encoding`.
   
   The cause is in `HttpConnectionManager.buildTargetResponse`, which copies 
the upstream headers with `res.Header.Get(k)`. `Get` returns only the first 
value. The loop now adds every value of each header. Request headers already 
reach the upstream with all their values, so only the response side changes.
   
   **Which issue(s) this PR fixes**:
   
   None filed. I found it while running the http-to-http sample.
   
   **Special notes for your reviewer**:
   
   `TestBuildTargetResponseKeepsRepeatedHeaders` passes an upstream response 
with two `Set-Cookie` values through `buildTargetResponse`. With the old loop 
it fails with `expected: []string{"session=abc; Path=/", "csrf=xyz; Path=/"}` 
and `actual: []string{"session=abc; Path=/"}`.
   
   I ran that test, `go test ./pkg/common/http/... ./pkg/context/http/... -race 
-gcflags=-l`, `gofmt -s`, `go tool imports-formatter` (no diff), `go vet 
./pkg/common/http/` and golangci-lint v2.4.0 with `--new-from-rev` (0 issues), 
on Go 1.25.14 in Docker. I also rebuilt the gateway from this branch and 
repeated the request: both cookies and both `Vary` values now reach the client. 
I did not run the full `go test ./...` or the samples integration suite.
   
   **Does this PR introduce a user-facing change?**:
   
   ```release-note
   The HTTP proxy now forwards every value of a repeated upstream response 
header, such as several Set-Cookie headers, instead of only the first one.
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to