-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setRequestDecoder to ResponseEncoder interface #24368
Changes from all commits
30a70cc
351ae73
fed169f
41876ee
e897a9d
7b6e5d6
6af9d70
e643111
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1747,9 +1747,6 @@ void ConnectionManagerImpl::ActiveStream::onRequestDataTooLarge() { | |
|
||
void ConnectionManagerImpl::ActiveStream::recreateStream( | ||
StreamInfo::FilterStateSharedPtr filter_state) { | ||
// n.b. we do not currently change the codecs to point at the new stream | ||
// decoder because the decoder callbacks are complete. It would be good to | ||
// null out that pointer but should not be necessary. | ||
ResponseEncoder* response_encoder = response_encoder_; | ||
response_encoder_ = nullptr; | ||
|
||
|
@@ -1767,6 +1764,12 @@ void ConnectionManagerImpl::ActiveStream::recreateStream( | |
connection_manager_.doEndStream(*this, /*check_for_deferred_close*/ false); | ||
|
||
RequestDecoder& new_stream = connection_manager_.newStream(*response_encoder, true); | ||
// Set the new RequestDecoder on the ResponseEncoder. Even though all of the decoder callbacks | ||
// have already been called at this point, the encoder still needs the new decoder for deferred | ||
// logging in some cases. | ||
// This doesn't currently work for HTTP/1 as the H/1 ResponseEncoder doesn't hold the active | ||
// stream's pointer to the RequestDecoder. | ||
Comment on lines
+1770
to
+1771
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my own knowledge, how does H1 codec decode request headers in that case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. H1 has an ActiveStream that has a handle on both a ResponseEncoder and RequestDecoder. So e.g. on receiving headers the connection goes through the active request to get to the decoder, like here. It seems like the H/2 and H/3 codecs have the decoding path go through the response encoder -> request decoder partly to simplify multiplexing, so it makes sense that H/1 (which doesn't have streams) is organized a bit differently. I could be wrong about that last part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get it! Thanks for the link! |
||
response_encoder->setRequestDecoder(new_stream); | ||
// We don't need to copy over the old parent FilterState from the old StreamInfo if it did not | ||
// store any objects with a LifeSpan at or above DownstreamRequest. This is to avoid unnecessary | ||
// heap allocation. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,11 @@ class ResponseEncoderImpl : public StreamEncoderImpl, public ResponseEncoder { | |
return stream_error_on_invalid_http_message_; | ||
} | ||
|
||
// For H/1, ResponseEncoder doesn't hold a pointer to RequestDecoder. | ||
// TODO(paulsohn): Enable H/1 codec to get a pointer to the new | ||
// request decoder on recreateStream, here or elsewhere. | ||
void setRequestDecoder(Http::RequestDecoder& /*decoder*/) override {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or maybe why HTTP/1.1 doesn't need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. H/1 will need more work to actually reset the decoder on internal redirect, but it seems like we don't need to tackle that now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need to make it work for H1 to defer logging I guess? Can you add a TODO? |
||
|
||
// Http1::StreamEncoderImpl | ||
void resetStream(StreamResetReason reason) override; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think it's worth a comment on why this is a useful association?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added, ptal!