Skip to content

Conversation

jhump
Copy link
Member

@jhump jhump commented Dec 14, 2023

This one's a little more confusing the client side because of how we to hook into the HTTP framework's response writer. We basically override the response writer to maybe ignore all calls to it (made by the handler to send its "normal" HTTP response) and, at the end, instead send the raw response. Because it waits until the end to send the raw response, we can't test full-duplex bidi stuff with it. But it does work fine with half-duplex bidi operations.

The "maybe" when ignoring calls is whether there is a raw response or not. So there's a connect interceptor that examines the request as the first thing and, if it contains a raw response, stashes it away so the overridden response writer knows about it. This "stashing away" uses a placeholder address in a context value.

@@ -54,6 +54,26 @@ func TestRawRequestSender(t *testing.T) {
err = anypb.MarshalFrom(msgPayload, val, proto.MarshalOptions{})
require.NoError(t, err)

var requests sync.Map // map[string]chan *http.Request
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file are admittedly unrelated. I was just moving stuff around to make it a little more consistent with the other tests (and maybe a little more readable?).

@jhump jhump enabled auto-merge (squash) December 18, 2023 18:26
@jhump jhump merged commit cea418d into main Dec 18, 2023
@jhump jhump deleted the jh/raw-resp-in-refsvr branch December 18, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants