aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/filters/http
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2018-09-13 15:16:02 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2018-09-13 15:16:02 -0700
commit1819935efbb2fb014c0c29bc47f5045fbcf5c6cf (patch)
treeb59127474ac1b007a44d4209caadc27e7355a52a /src/core/ext/filters/http
parent30e7b02b5c8bc55c109ed84dfa30663ce90e134b (diff)
parent07eecd8421314d62e8df33b14a33203864f91bee (diff)
Merge branch 'master' into statuscaution
Diffstat (limited to 'src/core/ext/filters/http')
-rw-r--r--src/core/ext/filters/http/server/http_server_filter.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc
index 90336103cf..cd3cab134a 100644
--- a/src/core/ext/filters/http/server/http_server_filter.cc
+++ b/src/core/ext/filters/http/server/http_server_filter.cc
@@ -23,6 +23,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <string.h>
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/b64.h"
@@ -69,6 +70,10 @@ struct call_data {
bool seen_recv_trailing_metadata_ready;
};
+struct channel_data {
+ bool surface_user_agent;
+};
+
} // namespace
static grpc_error* hs_filter_outgoing_metadata(grpc_call_element* elem,
@@ -265,6 +270,11 @@ static grpc_error* hs_filter_incoming_metadata(grpc_call_element* elem,
GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":authority")));
}
+ channel_data* chand = static_cast<channel_data*>(elem->channel_data);
+ if (!chand->surface_user_agent && b->idx.named.user_agent != nullptr) {
+ grpc_metadata_batch_remove(b, b->idx.named.user_agent);
+ }
+
return error;
}
@@ -451,7 +461,12 @@ static void hs_destroy_call_elem(grpc_call_element* elem,
/* Constructor for channel_data */
static grpc_error* hs_init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
+ channel_data* chand = static_cast<channel_data*>(elem->channel_data);
GPR_ASSERT(!args->is_last);
+ chand->surface_user_agent = grpc_channel_arg_get_bool(
+ grpc_channel_args_find(args->channel_args,
+ const_cast<char*>(GRPC_ARG_SURFACE_USER_AGENT)),
+ true);
return GRPC_ERROR_NONE;
}
@@ -465,7 +480,7 @@ const grpc_channel_filter grpc_http_server_filter = {
hs_init_call_elem,
grpc_call_stack_ignore_set_pollset_or_pollset_set,
hs_destroy_call_elem,
- 0,
+ sizeof(channel_data),
hs_init_channel_elem,
hs_destroy_channel_elem,
grpc_channel_next_get_info,