From 1148eb933587a05f300bc28fc85985013124c206 Mon Sep 17 00:00:00 2001 From: Jose Ulises Nino Rivera Date: Wed, 12 Oct 2016 12:15:51 -0700 Subject: [PATCH] Move content_type route config into headers (#141) --- configs/envoy_service_to_service.template.json | 4 +++- docs/configuration/http_conn_man/route_config/route.rst | 5 ----- examples/grpc-bridge/config/s2s-grpc-envoy.json | 4 +++- source/common/router/config_impl.cc | 8 ++------ source/common/router/config_impl.h | 1 - test/common/router/config_impl_test.cc | 4 +++- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/configs/envoy_service_to_service.template.json b/configs/envoy_service_to_service.template.json index 818c661a4394..a581d2261cb0 100644 --- a/configs/envoy_service_to_service.template.json +++ b/configs/envoy_service_to_service.template.json @@ -54,7 +54,9 @@ { "timeout_ms": 0, "prefix": "/", - "content_type": "application/grpc", + "headers": [ + {"name": "content-type", "value": "application/grpc"} + ], "cluster": "local_service_grpc" }, { diff --git a/docs/configuration/http_conn_man/route_config/route.rst b/docs/configuration/http_conn_man/route_config/route.rst index 033bbb643a8f..797a0ccb579e 100644 --- a/docs/configuration/http_conn_man/route_config/route.rst +++ b/docs/configuration/http_conn_man/route_config/route.rst @@ -18,7 +18,6 @@ next (e.g., redirect, forward, rewrite, etc.). "host_rewrite": "...", "case_sensitive": "...", "timeout_ms": "...", - "content_type": "...", "runtime": "{...}", "retry_policy": "{...}", "rate_limit": "{...}", @@ -75,10 +74,6 @@ timeout_ms :ref:`config_http_filters_router_x-envoy-upstream-rq-per-try-timeout-ms`, and the :ref:`retry overview `. -content_type - *(optional, string)* Indicates that the route should additionally match on the *content-type* - HTTP header. - :ref:`runtime ` *(optional, object)* Indicates that the route should additionally match on a runtime key. diff --git a/examples/grpc-bridge/config/s2s-grpc-envoy.json b/examples/grpc-bridge/config/s2s-grpc-envoy.json index 8397fd1aac63..e5fbddc7b989 100644 --- a/examples/grpc-bridge/config/s2s-grpc-envoy.json +++ b/examples/grpc-bridge/config/s2s-grpc-envoy.json @@ -20,7 +20,9 @@ { "timeout_ms": 0, "prefix": "/", - "content_type": "application/grpc", + "headers": [ + {"name": "content-type", "value": "application/grpc"} + ], "cluster": "local_service_grpc" } ] diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 4e38d35ff1ef..cfebac7c2e42 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -58,8 +58,8 @@ RouteEntryImplBase::RouteEntryImplBase(const VirtualHost& vhost, const Json::Obj runtime_(loadRuntimeData(route)), loader_(loader), host_redirect_(route.getString("host_redirect", "")), path_redirect_(route.getString("path_redirect", "")), retry_policy_(route), - content_type_(route.getString("content_type", "")), rate_limit_policy_(route), - shadow_policy_(route), priority_(ConfigUtility::parsePriority(route)) { + rate_limit_policy_(route), shadow_policy_(route), + priority_(ConfigUtility::parsePriority(route)) { // Check to make sure that we are either a redirect route or we have a cluster. if (!(isRedirect() ^ !cluster_name_.empty())) { @@ -84,10 +84,6 @@ bool RouteEntryImplBase::matches(const Http::HeaderMap& headers, uint64_t random random_value); } - if (!content_type_.empty()) { - matches &= (headers.get(Http::Headers::get().ContentType) == content_type_); - } - if (!config_headers_.empty()) { for (const HeaderData& header_data : config_headers_) { if (header_data.value_ == EMPTY_STRING) { diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index a774e3840b38..73526329734e 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -215,7 +215,6 @@ class RouteEntryImplBase : public RouteEntry, public Matchable, public RedirectE const std::string host_redirect_; const std::string path_redirect_; const RetryPolicyImpl retry_policy_; - const std::string content_type_; const RateLimitPolicyImpl rate_limit_policy_; const ShadowPolicyImpl shadow_policy_; const Upstream::ResourcePriority priority_; diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index 2f871417bbd8..c8f12adef86d 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -487,7 +487,9 @@ TEST(RouteMatcherTest, ContentType) { { "prefix": "/", "cluster": "local_service_grpc", - "content_type": "application/grpc" + "headers" : [ + {"name": "content-type", "value": "application/grpc"} + ] }, { "prefix": "/",