Skip to content

Commit

Permalink
Add local_end_stream_ to crash dump for H1 (envoyproxy#17367)
Browse files Browse the repository at this point in the history
Risk Level: low
Testing: unit test improvements
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Pradeep Rao <[email protected]>
  • Loading branch information
pradeepcrao authored and Le Yao committed Sep 30, 2021
1 parent 2ae0185 commit d50d575
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
14 changes: 9 additions & 5 deletions source/common/http/http1/codec_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,8 @@ void ConnectionImpl::dumpState(std::ostream& os, int indent_level) const {

void ServerConnectionImpl::dumpAdditionalState(std::ostream& os, int indent_level) const {
const char* spaces = spacesForLevel(indent_level);
os << DUMP_MEMBER_AS(active_request_.request_url_,
active_request_.has_value() &&
!active_request_.value().request_url_.getStringView().empty()
? active_request_.value().request_url_.getStringView()
: "null");

DUMP_DETAILS(active_request_);
os << '\n';

// Dump header map, it may be null if it was moved to the request, and
Expand Down Expand Up @@ -1228,6 +1225,13 @@ Status ServerConnectionImpl::checkHeaderNameForUnderscores() {
return okStatus();
}

void ServerConnectionImpl::ActiveRequest::dumpState(std::ostream& os, int indent_level) const {
(void)indent_level;
os << DUMP_MEMBER_AS(
request_url_, !request_url_.getStringView().empty() ? request_url_.getStringView() : "null");
os << DUMP_MEMBER(response_encoder_.local_end_stream_);
}

ClientConnectionImpl::ClientConnectionImpl(Network::Connection& connection, CodecStats& stats,
ConnectionCallbacks&, const Http1Settings& settings,
const uint32_t max_response_headers_count)
Expand Down
1 change: 1 addition & 0 deletions source/common/http/http1/codec_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ class ServerConnectionImpl : public ServerConnection, public ConnectionImpl {
: response_encoder_(connection,
connection.codec_settings_.stream_error_on_invalid_http_message_) {}

void dumpState(std::ostream& os, int indent_level) const;
HeaderString request_url_;
RequestDecoder* request_decoder_{};
ResponseEncoderImpl response_encoder_;
Expand Down
3 changes: 2 additions & 1 deletion test/common/http/http1/codec_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,8 @@ TEST_F(Http1ServerConnectionImplTest, ShouldDumpDispatchBufferWithoutAllocatingM
// Check dump contents
EXPECT_THAT(ostream.contents(), HasSubstr("buffered_body_.length(): 5, header_parsing_state_: "
"Done, current_header_field_: , current_header_value_: "
"\n, active_request_.request_url_: null"));
"\nactive_request_: \n, request_url_: null"
", response_encoder_.local_end_stream_: 0"));
EXPECT_THAT(ostream.contents(),
HasSubstr("current_dispatching_buffer_ front_slice length: 43 contents: \"POST / "
"HTTP/1.1\\r\\nContent-Length: 5\\r\\n\\r\\nHello\"\n"));
Expand Down

0 comments on commit d50d575

Please sign in to comment.