grpclb: skip slash in server uri path if present

pull/9144/head
David Garcia Quintas 8 years ago
parent 2cf4f35a38
commit 855a1063ec
  1. 10
      src/core/ext/lb_policy/grpclb/grpclb.c
  2. 2
      test/cpp/grpclb/grpclb_test.cc

@ -768,8 +768,14 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI); arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
GPR_ASSERT(arg != NULL); GPR_ASSERT(arg != NULL);
GPR_ASSERT(arg->type == GRPC_ARG_STRING); GPR_ASSERT(arg->type == GRPC_ARG_STRING);
grpc_uri *uri = grpc_uri_parse(arg->value.string, 1); grpc_uri *uri = grpc_uri_parse(arg->value.string, true);
glb_policy->server_name = gpr_strdup(uri->path); GPR_ASSERT(uri->path[0] != '\0');
glb_policy->server_name =
gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Will use '%s' as the server name for LB request.",
glb_policy->server_name);
}
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
/* All input addresses in addresses come from a resolver that claims /* All input addresses in addresses come from a resolver that claims

@ -659,7 +659,7 @@ static test_fixture setup_test_fixture(int lb_server_update_delay_ms) {
char *server_uri; char *server_uri;
// The grpclb LB policy will be automatically selected by virtue of // The grpclb LB policy will be automatically selected by virtue of
// the fact that the returned addresses are balancer addresses. // the fact that the returned addresses are balancer addresses.
gpr_asprintf(&server_uri, "test:%s?lb_enabled=1", gpr_asprintf(&server_uri, "test:///%s?lb_enabled=1",
tf.lb_server.servers_hostport); tf.lb_server.servers_hostport);
setup_client(server_uri, &tf.client); setup_client(server_uri, &tf.client);
gpr_free(server_uri); gpr_free(server_uri);

Loading…
Cancel
Save