/proc/self/cwd/source/common/http/http1/settings.cc
Line | Count | Source |
1 | | #include "source/common/http/http1/settings.h" |
2 | | |
3 | | #include "envoy/http/header_formatter.h" |
4 | | |
5 | | #include "source/common/config/utility.h" |
6 | | #include "source/common/runtime/runtime_features.h" |
7 | | |
8 | | namespace Envoy { |
9 | | namespace Http { |
10 | | namespace Http1 { |
11 | | |
12 | | Http1Settings parseHttp1Settings(const envoy::config::core::v3::Http1ProtocolOptions& config, |
13 | 9.78k | ProtobufMessage::ValidationVisitor& validation_visitor) { |
14 | 9.78k | Http1Settings ret; |
15 | 9.78k | ret.allow_absolute_url_ = PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, allow_absolute_url, true); |
16 | 9.78k | ret.accept_http_10_ = config.accept_http_10(); |
17 | 9.78k | ret.send_fully_qualified_url_ = config.send_fully_qualified_url(); |
18 | 9.78k | ret.default_host_for_http_10_ = config.default_host_for_http_10(); |
19 | 9.78k | ret.enable_trailers_ = config.enable_trailers(); |
20 | 9.78k | ret.allow_chunked_length_ = config.allow_chunked_length(); |
21 | | |
22 | 9.78k | if (config.header_key_format().has_proper_case_words()) { |
23 | 75 | ret.header_key_format_ = Http1Settings::HeaderKeyFormat::ProperCase; |
24 | 9.71k | } else if (config.header_key_format().has_stateful_formatter()) { |
25 | 7 | auto& factory = |
26 | 7 | Config::Utility::getAndCheckFactory<Envoy::Http::StatefulHeaderKeyFormatterFactoryConfig>( |
27 | 7 | config.header_key_format().stateful_formatter()); |
28 | 7 | auto header_formatter_config = Envoy::Config::Utility::translateAnyToFactoryConfig( |
29 | 7 | config.header_key_format().stateful_formatter().typed_config(), validation_visitor, |
30 | 7 | factory); |
31 | 7 | ret.header_key_format_ = Http1Settings::HeaderKeyFormat::StatefulFormatter; |
32 | 7 | ret.stateful_header_key_formatter_ = factory.createFromProto(*header_formatter_config); |
33 | 7 | } |
34 | | |
35 | 9.78k | if (config.has_use_balsa_parser()) { |
36 | 523 | ret.use_balsa_parser_ = config.use_balsa_parser().value(); |
37 | 9.26k | } else { |
38 | 9.26k | ret.use_balsa_parser_ = |
39 | 9.26k | Runtime::runtimeFeatureEnabled("envoy.reloadable_features.http1_use_balsa_parser"); |
40 | 9.26k | } |
41 | | |
42 | 9.78k | ret.allow_custom_methods_ = config.allow_custom_methods(); |
43 | | |
44 | 9.78k | return ret; |
45 | 9.78k | } |
46 | | |
47 | | Http1Settings parseHttp1Settings(const envoy::config::core::v3::Http1ProtocolOptions& config, |
48 | | ProtobufMessage::ValidationVisitor& validation_visitor, |
49 | | const ProtobufWkt::BoolValue& hcm_stream_error, |
50 | 6.51k | bool validate_scheme) { |
51 | 6.51k | Http1Settings ret = parseHttp1Settings(config, validation_visitor); |
52 | 6.51k | ret.validate_scheme_ = validate_scheme; |
53 | | |
54 | 6.51k | if (config.has_override_stream_error_on_invalid_http_message()) { |
55 | | // override_stream_error_on_invalid_http_message, if set, takes precedence over any HCM |
56 | | // stream_error_on_invalid_http_message |
57 | 268 | ret.stream_error_on_invalid_http_message_ = |
58 | 268 | config.override_stream_error_on_invalid_http_message().value(); |
59 | 6.25k | } else { |
60 | | // fallback to HCM value |
61 | 6.25k | ret.stream_error_on_invalid_http_message_ = hcm_stream_error.value(); |
62 | 6.25k | } |
63 | | |
64 | 6.51k | return ret; |
65 | 6.51k | } |
66 | | |
67 | | } // namespace Http1 |
68 | | } // namespace Http |
69 | | } // namespace Envoy |