Surface user agent by default

pull/16558/head
ncteisen 6 years ago
parent c9e300d5b0
commit 16f53ff583
  1. 3
      include/grpc/impl/codegen/grpc_types.h
  2. 2
      src/core/ext/filters/http/server/http_server_filter.cc
  3. 9
      test/core/end2end/tests/workaround_cronet_compression.cc
  4. 13
      test/cpp/end2end/end2end_test.cc

@ -342,7 +342,8 @@ typedef struct {
"grpc.disable_client_authority_filter"
/** If set to zero, disables use of http proxies. Enabled by default. */
#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy"
/** If set to non zero, surfaces the user agent string to the server. */
/** If set to non zero, surfaces the user agent string to the server. User
agent is surfaced by default. */
#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent"
/** \} */

@ -445,7 +445,7 @@ static grpc_error* hs_init_channel_elem(grpc_channel_element* elem,
chand->surface_user_agent = grpc_channel_arg_get_bool(
grpc_channel_args_find(args->channel_args,
const_cast<char*>(GRPC_ARG_SURFACE_USER_AGENT)),
false);
true);
return GRPC_ERROR_NONE;
}

@ -149,15 +149,6 @@ static void request_with_payload_template(
arg.value.string = user_agent_override;
client_args = grpc_channel_args_copy_and_add(client_args_old, &arg, 1);
grpc_channel_args_destroy(client_args_old);
// force grpc lib to pass the user agent back up to server.
grpc_channel_args* server_args_old = server_args;
grpc_arg server_arg;
server_arg.key = const_cast<char*>(GRPC_ARG_SURFACE_USER_AGENT);
server_arg.type = GRPC_ARG_INTEGER;
server_arg.value.integer = 1;
server_args =
grpc_channel_args_copy_and_add(server_args_old, &server_arg, 1);
grpc_channel_args_destroy(server_args_old);
}
f = begin_test(config, test_name, client_args, server_args);

@ -244,17 +244,15 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
BuildAndStartServer(processor);
}
void RestartServer(const std::shared_ptr<AuthMetadataProcessor>& processor,
bool surface_user_agent = false) {
void RestartServer(const std::shared_ptr<AuthMetadataProcessor>& processor) {
if (is_server_started_) {
server_->Shutdown();
BuildAndStartServer(processor, surface_user_agent);
BuildAndStartServer(processor);
}
}
void BuildAndStartServer(
const std::shared_ptr<AuthMetadataProcessor>& processor,
bool surface_user_agent = false) {
const std::shared_ptr<AuthMetadataProcessor>& processor) {
ServerBuilder builder;
ConfigureServerBuilder(&builder);
auto server_creds = GetCredentialsProvider()->GetServerCredentials(
@ -270,9 +268,6 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
builder.SetSyncServerOption(ServerBuilder::SyncServerOption::NUM_CQS, 4);
builder.SetSyncServerOption(
ServerBuilder::SyncServerOption::CQ_TIMEOUT_MSEC, 10);
if (surface_user_agent) {
builder.AddChannelArgument(GRPC_ARG_SURFACE_USER_AGENT, 1);
}
server_ = builder.BuildAndStart();
is_server_started_ = true;
@ -669,8 +664,6 @@ TEST_P(End2endTest, SimpleRpcWithCustomUserAgentPrefix) {
}
user_agent_prefix_ = "custom_prefix";
ResetStub();
RestartServer(std::shared_ptr<AuthMetadataProcessor>(), true);
ResetChannel();
EchoRequest request;
EchoResponse response;
request.set_message("Hello hello hello hello");

Loading…
Cancel
Save