forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhttp_protocol_integration.cc
141 lines (128 loc) · 5.51 KB
/
http_protocol_integration.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "test/integration/http_protocol_integration.h"
#include "absl/strings/str_cat.h"
namespace Envoy {
std::vector<HttpProtocolTestParams> HttpProtocolIntegrationTest::getProtocolTestParams(
const std::vector<Http::CodecType>& downstream_protocols,
const std::vector<Http::CodecType>& upstream_protocols) {
std::vector<HttpProtocolTestParams> ret;
for (auto ip_version : TestEnvironment::getIpVersionsForTest()) {
for (auto downstream_protocol : downstream_protocols) {
for (auto upstream_protocol : upstream_protocols) {
#ifndef ENVOY_ENABLE_QUIC
if (downstream_protocol == Http::CodecType::HTTP3 ||
upstream_protocol == Http::CodecType::HTTP3) {
ENVOY_LOG_MISC(warn, "Skipping HTTP/3 as support is compiled out");
continue;
}
#endif
std::vector<Http1ParserImpl> http1_implementations = {Http1ParserImpl::HttpParser};
if (downstream_protocol == Http::CodecType::HTTP1 ||
upstream_protocol == Http::CodecType::HTTP1) {
http1_implementations.push_back(Http1ParserImpl::BalsaParser);
}
std::vector<Http2Impl> http2_implementations = {Http2Impl::Nghttp2};
std::vector<bool> defer_processing_values = {false};
if (downstream_protocol == Http::CodecType::HTTP2 ||
upstream_protocol == Http::CodecType::HTTP2) {
http2_implementations.push_back(Http2Impl::Oghttp2);
defer_processing_values.push_back(true);
}
std::vector<bool> use_header_validator_values;
#ifdef ENVOY_ENABLE_UHV
use_header_validator_values.push_back(true);
#else
use_header_validator_values.push_back(false);
#endif
for (Http1ParserImpl http1_implementation : http1_implementations) {
for (Http2Impl http2_implementation : http2_implementations) {
for (bool defer_processing : defer_processing_values) {
for (bool use_header_validator : use_header_validator_values) {
ret.push_back(HttpProtocolTestParams{
ip_version, downstream_protocol, upstream_protocol, http1_implementation,
http2_implementation, defer_processing, use_header_validator});
}
}
}
}
}
}
}
return ret;
}
absl::string_view upstreamToString(Http::CodecType type) {
switch (type) {
case Http::CodecType::HTTP1:
return "HttpUpstream";
case Http::CodecType::HTTP2:
return "Http2Upstream";
case Http::CodecType::HTTP3:
return "Http3Upstream";
}
return "UnknownUpstream";
}
absl::string_view downstreamToString(Http::CodecType type) {
switch (type) {
case Http::CodecType::HTTP1:
return "HttpDownstream_";
case Http::CodecType::HTTP2:
return "Http2Downstream_";
case Http::CodecType::HTTP3:
return "Http3Downstream_";
}
return "UnknownDownstream";
}
absl::string_view http2ImplementationToString(Http2Impl impl) {
switch (impl) {
case Http2Impl::Nghttp2:
return "Nghttp2";
case Http2Impl::Oghttp2:
return "Oghttp2";
}
return "UnknownHttp2Impl";
}
std::string HttpProtocolIntegrationTest::protocolTestParamsToString(
const ::testing::TestParamInfo<HttpProtocolTestParams>& params) {
return absl::StrCat((params.param.version == Network::Address::IpVersion::v4 ? "IPv4_" : "IPv6_"),
downstreamToString(params.param.downstream_protocol),
upstreamToString(params.param.upstream_protocol),
TestUtility::http1ParserImplToString(params.param.http1_implementation),
http2ImplementationToString(params.param.http2_implementation),
params.param.defer_processing_backedup_streams ? "WithDeferredProcessing"
: "NoDeferredProcessing",
params.param.use_universal_header_validator ? "Uhv" : "Legacy");
}
void HttpProtocolIntegrationTest::setUpstreamOverrideStreamErrorOnInvalidHttpMessage() {
config_helper_.addConfigModifier([&](envoy::config::bootstrap::v3::Bootstrap& bootstrap) -> void {
RELEASE_ASSERT(bootstrap.mutable_static_resources()->clusters_size() >= 1, "");
ConfigHelper::HttpProtocolOptions protocol_options;
if (upstreamProtocol() == Http::CodecType::HTTP2) {
protocol_options.mutable_explicit_http_config()
->mutable_http2_protocol_options()
->mutable_override_stream_error_on_invalid_http_message()
->set_value(true);
} else {
protocol_options.mutable_explicit_http_config()
->mutable_http3_protocol_options()
->mutable_override_stream_error_on_invalid_http_message()
->set_value(true);
}
ConfigHelper::setProtocolOptions(*bootstrap.mutable_static_resources()->mutable_clusters(0),
protocol_options);
});
}
void HttpProtocolIntegrationTest::setDownstreamOverrideStreamErrorOnInvalidHttpMessage() {
config_helper_.addConfigModifier(
[](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) -> void {
hcm.mutable_http3_protocol_options()
->mutable_override_stream_error_on_invalid_http_message()
->set_value(true);
hcm.mutable_http2_protocol_options()
->mutable_override_stream_error_on_invalid_http_message()
->set_value(true);
hcm.mutable_http_protocol_options()
->mutable_override_stream_error_on_invalid_http_message()
->set_value(true);
});
}
} // namespace Envoy