Lcos-000 opened a new pull request, #3668: URL: https://github.com/apache/dubbo-go/pull/3668
## What & why `SendHeader` is documented to "append response headers from a server handler and send them immediately" (same semantics as `SetHeader`, but flushed on the first `Send`). Its implementation merged the user-supplied headers into `conn.RequestHeader()` instead of `conn.ResponseHeader()`, so: 1. **Response headers were silently dropped** — `grpcHandlerConn.Send` only flushes `hc.responseHeader` into the response writer, so the user's headers never reached the client. 2. **Request headers were polluted** — the headers were merged into the shared inbound request header map, so subsequent `RequestHeader()` / `FromIncomingContext` reads observed headers the client never sent. Align with the sibling `SetHeader` (`header.go:263`) by writing into `conn.ResponseHeader()`. Closes #3667. ## Changes - `protocol/triple/triple_protocol/header.go:312` — `conn.RequestHeader()` → `conn.ResponseHeader()`. - `protocol/triple/triple_protocol/header_test.go` — upgrade `mockHandlerConn` to expose a real `RequestHeader` map and a `Send` call counter (the old `RequestHeader()` returned `nil`, which masked any pollution); add `TestSendHeader` (asserts headers land in `ResponseHeader()`, `RequestHeader()` is **not** mutated, and `Send` is called once) and `TestSendHeaderOutsideHandler` (asserts `CodeInternal`). - `protocol/triple/triple_protocol/triple_ext_test.go` — add `TestSendHeaderInUnaryHandler`, an end-to-end test over a real `httptest` HTTP transport. The mock in `header_test.go` does not simulate `net/http`'s `WriteHeader` snapshot semantics, so it could not catch the "headers never reach the wire" failure mode. This test also covers the unary handler's double-`Send` path (`SendHeader`'s `conn.Send(nil)` followed by the framework's `conn.Send(msg)`) and verifies the response body stays decodable after the header flush. ## Verification - Confirmed `TestSendHeader` (mock) and `TestSendHeaderInUnaryHandler` (e2e) both **FAIL** on the pre-fix code (`got: []` / `got: []`), proving the new tests reproduce the bug. - After the one-line fix, both pass; the full `protocol/triple/triple_protocol` package test suite is green; `go vet` / `go build` clean. ## Notes - Based on the latest `origin/develop` (a31acfb6). - Scope is intentionally limited to the public `SendHeader` API. The compat layer's `compatHandlerStream.SendHeader` remains a documented no-op (handled by #3663) and is out of scope. - A streaming e2e covering `grpcHandlerConn.Send`'s flush path would be a natural follow-up, but is left to a separate change to keep this fix focused. -- 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]
