aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-01-14 14:59:53 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-01-14 14:59:53 -0800
commit8dfaae6984f030906d34640468a1303d7e90edbf (patch)
tree148b0769dcea8841cc8b97c0b93ee96226b461f7 /src/core
parentc6a56dfd45b7a30d12911ec13d4fa0b59054fd5f (diff)
parented0cbc8b0ca43e247fd3404390b37754ee2c90f2 (diff)
Merge pull request #22 from dklempner/http_scheme
Send a scheme of http or https as appropriate, rather than grpc.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/channel/http_client_filter.c17
-rw-r--r--src/core/channel/http_client_filter.h2
-rw-r--r--src/core/security/security_context.c11
3 files changed, 28 insertions, 2 deletions
diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c
index 98e26aa563..ab9d3aff16 100644
--- a/src/core/channel/http_client_filter.c
+++ b/src/core/channel/http_client_filter.c
@@ -32,6 +32,7 @@
*/
#include "src/core/channel/http_client_filter.h"
+#include <string.h>
#include <grpc/support/log.h>
typedef struct call_data { int sent_headers; } call_data;
@@ -130,6 +131,19 @@ static void destroy_call_elem(grpc_call_element *elem) {
ignore_unused(channeld);
}
+static const char *scheme_from_args(const grpc_channel_args *args) {
+ int i;
+ if (args != NULL) {
+ for (i = 0; i < args->num_args; ++i) {
+ if (args->args[i].type == GRPC_ARG_STRING &&
+ strcmp(args->args[i].key, GRPC_ARG_HTTP2_SCHEME) == 0) {
+ return args->args[i].value.string;
+ }
+ }
+ }
+ return "http";
+}
+
/* Constructor for channel_data */
static void init_channel_elem(grpc_channel_element *elem,
const grpc_channel_args *args, grpc_mdctx *mdctx,
@@ -146,7 +160,8 @@ static void init_channel_elem(grpc_channel_element *elem,
/* initialize members */
channeld->te_trailers = grpc_mdelem_from_strings(mdctx, "te", "trailers");
channeld->method = grpc_mdelem_from_strings(mdctx, ":method", "POST");
- channeld->scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "grpc");
+ channeld->scheme =
+ grpc_mdelem_from_strings(mdctx, ":scheme", scheme_from_args(args));
channeld->content_type =
grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc");
}
diff --git a/src/core/channel/http_client_filter.h b/src/core/channel/http_client_filter.h
index f939cbd351..21cde4877b 100644
--- a/src/core/channel/http_client_filter.h
+++ b/src/core/channel/http_client_filter.h
@@ -39,4 +39,6 @@
/* Processes metadata on the client side for HTTP2 transports */
extern const grpc_channel_filter grpc_http_client_filter;
+#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme"
+
#endif /* __GRPC_INTERNAL_CHANNEL_HTTP_CLIENT_FILTER_H__ */
diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c
index d519ecab87..fc722f2d82 100644
--- a/src/core/security/security_context.c
+++ b/src/core/security/security_context.c
@@ -35,6 +35,8 @@
#include <string.h>
+#include "src/core/channel/channel_args.h"
+#include "src/core/channel/http_client_filter.h"
#include "src/core/security/credentials.h"
#include "src/core/security/secure_endpoint.h"
#include "src/core/surface/lame_client.h"
@@ -444,6 +446,8 @@ grpc_channel *grpc_ssl_channel_create(grpc_credentials *ssl_creds,
grpc_security_status status = GRPC_SECURITY_OK;
size_t i = 0;
const char *secure_peer_name = target;
+ grpc_arg arg;
+ grpc_channel_args *new_args;
for (i = 0; args && i < args->num_args; i++) {
grpc_arg *arg = &args->args[i];
@@ -459,8 +463,13 @@ grpc_channel *grpc_ssl_channel_create(grpc_credentials *ssl_creds,
if (status != GRPC_SECURITY_OK) {
return grpc_lame_client_channel_create();
}
- channel = grpc_secure_channel_create_internal(target, args, ctx);
+ arg.type = GRPC_ARG_STRING;
+ arg.key = GRPC_ARG_HTTP2_SCHEME;
+ arg.value.string = "https";
+ new_args = grpc_channel_args_copy_and_add(args, &arg);
+ channel = grpc_secure_channel_create_internal(target, new_args, ctx);
grpc_security_context_unref(&ctx->base);
+ grpc_channel_args_destroy(new_args);
return channel;
}