Lcos-000 opened a new pull request, #1139:
URL: https://github.com/apache/dubbo-go-samples/pull/1139

   ## What & why
   
   Exercise `triple.SendHeader` in the unary `Greet` handler (in addition to 
the existing `SetHeader`) and assert the flushed header reaches the client. 
This turns the `triple_header_trailer` integration test into a regression test 
for apache/dubbo-go#3667.
   
   Before apache/dubbo-go#3668, `SendHeader` merged user headers into 
`conn.RequestHeader()` instead of `conn.ResponseHeader()`, so:
   
   - **Response headers were silently dropped** — `grpcHandlerConn.Send` only 
flushes `hc.responseHeader` into the response writer, so the user's headers 
never reached the client.
   - **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.
   
   The current sample never called `SendHeader` (repo-wide grep: 0 matches; the 
server uses `SetHeader`/`SetTrailer` and `stream.ResponseHeader().Set()`, all 
of which go through the correct `conn.ResponseHeader()` path). The integration 
test only checks the client exit code, with assertions targeting only keys 
written via the correct paths — so the buggy `SendHeader` path was never 
exercised and CI stayed green.
   
   ## Changes
   
   - `go-server/cmd/main.go`: add `unarySendHeaderKey = 
"X-Unary-Send-Response"`; in the unary `Greet` handler, call 
`triple.SendHeader(ctx, http.Header{unarySendHeaderKey: 
{"unary-send-header"}})` after the existing `SetHeader` (order matters: 
`SetHeader` → `SendHeader` → `SetTrailer`, so `SendHeader`'s flush does not 
snapshot the writer headers before `SetHeader`'s value is staged).
   - `go-client/cmd/main.go`: add the same constant; log the new key and assert 
`requireHeader(responseHeader, unarySendHeaderKey, "unary-send-header")` right 
after the existing `X-Unary-Response` assertion.
   - `README.md` / `README_CN.md`: document `triple.SendHeader` in the 
demonstrated-API list and explain the SetHeader (buffered) vs SendHeader 
(immediate flush) semantics.
   
   ## Verification
   
   Pointed \`go.mod\` at dubbo-go via \`go mod edit -replace\` and ran the 
sample end-to-end against both the buggy and fixed dubbo-go revisions:
   
   | dubbo-go revision | `X-Unary-Send-Response` received | new assertion | 
client exit |
   |---|---|---|---|
   | \`main\` (buggy, apache/dubbo-go#3667) | \`[]\` | \`panic: missing header 
X-Unary-Send-Response="unary-send-header"\` | 1 ❌ |
   | \`pr-3668\` (fixed) | \`[unary-send-header]\` | passes | 0 ✅ |
   
   The existing \`X-Unary-Response\` (via \`SetHeader\`) still arrives under 
both revisions, confirming the change is path-specific and does not disturb the 
original demo. All four call types (unary, bidi-stream, client-stream, 
server-stream) pass on the fixed revision.
   
   \`go.mod\` / \`go.sum\` are untouched (the \`replace\` was only used for 
local verification and dropped before commit); \`gofmt\` clean.
   
   ## Notes
   
   Depends on apache/dubbo-go#3668 for the assertion to pass. If this PR lands 
before the framework fix, the integration test will fail on \`main\` — which is 
the intended signal.
   
   Refs: apache/dubbo-go#3668, apache/dubbo-go#3667


-- 
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