Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,57 @@ TEST_P(ExtProcIntegrationTest, ServerHalfClosesAfterHeaders) {
verifyDownstreamResponse(*response, 200);
}

TEST_P(ExtProcIntegrationTest, ServerHalfClosesDuringBodyStream) {
// Configure ext_proc to send both headers and body
proto_config_.mutable_processing_mode()->set_request_header_mode(ProcessingMode::SEND);
proto_config_.mutable_processing_mode()->set_request_body_mode(ProcessingMode::STREAMED);
proto_config_.mutable_processing_mode()->set_request_trailer_mode(ProcessingMode::SKIP);
proto_config_.mutable_processing_mode()->set_response_header_mode(ProcessingMode::SKIP);
proto_config_.set_failure_mode_allow(true);

initializeConfig();
HttpIntegrationTest::initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
Http::TestRequestHeaderMapImpl headers;
HttpTestUtility::addDefaultHeaders(headers);
auto encoder_decoder = codec_client_->startRequest(headers);
request_encoder_ = &encoder_decoder.first;

processRequestHeadersMessage(*grpc_upstreams_[0], true,
[](const HttpHeaders& headers, HeadersResponse&) {
EXPECT_FALSE(headers.end_of_stream());
return true;
});

// Client sends 7 chunks.
for (int i = 0; i < 7; ++i) {
if (i == 6) {
codec_client_->sendData(*request_encoder_, 1, true);
} else {
codec_client_->sendData(*request_encoder_, 1, false);
}
if (i < 4) {
processRequestBodyMessage(*grpc_upstreams_[0], false,
[](const HttpBody& body, BodyResponse&) {
EXPECT_FALSE(body.end_of_stream());
return true;
});
}
}

processor_stream_->finishGrpcStream(Grpc::Status::Internal);

// Even if the gRPC server half-closed, processing of the main request still continues.
// Verify that data made it to upstream.
// codec_client_->sendData(*request_encoder_, 0, true);
IntegrationStreamDecoderPtr response = std::move(encoder_decoder.second);

handleUpstreamRequest();
EXPECT_EQ(upstream_request_->bodyLength(), 7);
verifyDownstreamResponse(*response, 200);
}

// Test the filter using the default configuration by connecting to
// an ext_proc server that responds to the request_headers message
// by requesting to modify the request headers.
Expand Down