Line data Source code
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 299 : ProtobufMessage::ValidationVisitor& validation_visitor) { 14 299 : Http1Settings ret; 15 299 : ret.allow_absolute_url_ = PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, allow_absolute_url, true); 16 299 : ret.accept_http_10_ = config.accept_http_10(); 17 299 : ret.send_fully_qualified_url_ = config.send_fully_qualified_url(); 18 299 : ret.default_host_for_http_10_ = config.default_host_for_http_10(); 19 299 : ret.enable_trailers_ = config.enable_trailers(); 20 299 : ret.allow_chunked_length_ = config.allow_chunked_length(); 21 : 22 299 : if (config.header_key_format().has_proper_case_words()) { 23 0 : ret.header_key_format_ = Http1Settings::HeaderKeyFormat::ProperCase; 24 299 : } else if (config.header_key_format().has_stateful_formatter()) { 25 0 : auto& factory = 26 0 : Config::Utility::getAndCheckFactory<Envoy::Http::StatefulHeaderKeyFormatterFactoryConfig>( 27 0 : config.header_key_format().stateful_formatter()); 28 0 : auto header_formatter_config = Envoy::Config::Utility::translateAnyToFactoryConfig( 29 0 : config.header_key_format().stateful_formatter().typed_config(), validation_visitor, 30 0 : factory); 31 0 : ret.header_key_format_ = Http1Settings::HeaderKeyFormat::StatefulFormatter; 32 0 : ret.stateful_header_key_formatter_ = factory.createFromProto(*header_formatter_config); 33 0 : } 34 : 35 299 : if (config.has_use_balsa_parser()) { 36 0 : ret.use_balsa_parser_ = config.use_balsa_parser().value(); 37 299 : } else { 38 299 : ret.use_balsa_parser_ = 39 299 : Runtime::runtimeFeatureEnabled("envoy.reloadable_features.http1_use_balsa_parser"); 40 299 : } 41 : 42 299 : ret.allow_custom_methods_ = config.allow_custom_methods(); 43 : 44 299 : return ret; 45 299 : } 46 : 47 : Http1Settings parseHttp1Settings(const envoy::config::core::v3::Http1ProtocolOptions& config, 48 : ProtobufMessage::ValidationVisitor& validation_visitor, 49 : const ProtobufWkt::BoolValue& hcm_stream_error, 50 140 : bool validate_scheme) { 51 140 : Http1Settings ret = parseHttp1Settings(config, validation_visitor); 52 140 : ret.validate_scheme_ = validate_scheme; 53 : 54 140 : 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 0 : ret.stream_error_on_invalid_http_message_ = 58 0 : config.override_stream_error_on_invalid_http_message().value(); 59 140 : } else { 60 : // fallback to HCM value 61 140 : ret.stream_error_on_invalid_http_message_ = hcm_stream_error.value(); 62 140 : } 63 : 64 140 : return ret; 65 140 : } 66 : 67 : } // namespace Http1 68 : } // namespace Http 69 : } // namespace Envoy