aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/http
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-11-03 09:09:36 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-11-03 09:09:36 -0700
commitbaa14a975ef92ee6fb301f0e684f56f18f2c55a7 (patch)
tree9a6cb2df58fe175e8abfccf2cbd40349726e46f3 /src/core/lib/http
parentef68fe7239a89095f1eaa89c1dd28b2b7be2a3c7 (diff)
Update clang-format to 5.0
Diffstat (limited to 'src/core/lib/http')
-rw-r--r--src/core/lib/http/format_request.cc20
-rw-r--r--src/core/lib/http/format_request.h8
-rw-r--r--src/core/lib/http/httpcli.cc145
-rw-r--r--src/core/lib/http/httpcli.h64
-rw-r--r--src/core/lib/http/httpcli_security_connector.cc92
-rw-r--r--src/core/lib/http/parser.cc76
-rw-r--r--src/core/lib/http/parser.h38
7 files changed, 222 insertions, 221 deletions
diff --git a/src/core/lib/http/format_request.cc b/src/core/lib/http/format_request.cc
index 88fb0ab0b6..f3f3cbda7b 100644
--- a/src/core/lib/http/format_request.cc
+++ b/src/core/lib/http/format_request.cc
@@ -28,8 +28,8 @@
#include <grpc/support/useful.h>
#include "src/core/lib/support/string.h"
-static void fill_common_header(const grpc_httpcli_request *request,
- gpr_strvec *buf, bool connection_close) {
+static void fill_common_header(const grpc_httpcli_request* request,
+ gpr_strvec* buf, bool connection_close) {
size_t i;
gpr_strvec_add(buf, gpr_strdup(request->http.path));
gpr_strvec_add(buf, gpr_strdup(" HTTP/1.0\r\n"));
@@ -51,9 +51,9 @@ static void fill_common_header(const grpc_httpcli_request *request,
}
grpc_slice grpc_httpcli_format_get_request(
- const grpc_httpcli_request *request) {
+ const grpc_httpcli_request* request) {
gpr_strvec out;
- char *flat;
+ char* flat;
size_t flat_len;
gpr_strvec_init(&out);
@@ -67,11 +67,11 @@ grpc_slice grpc_httpcli_format_get_request(
return grpc_slice_new(flat, flat_len, gpr_free);
}
-grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
- const char *body_bytes,
+grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
+ const char* body_bytes,
size_t body_size) {
gpr_strvec out;
- char *tmp;
+ char* tmp;
size_t out_len;
size_t i;
@@ -98,7 +98,7 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
gpr_strvec_destroy(&out);
if (body_bytes) {
- tmp = (char *)gpr_realloc(tmp, out_len + body_size);
+ tmp = (char*)gpr_realloc(tmp, out_len + body_size);
memcpy(tmp + out_len, body_bytes, body_size);
out_len += body_size;
}
@@ -107,14 +107,14 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
}
grpc_slice grpc_httpcli_format_connect_request(
- const grpc_httpcli_request *request) {
+ const grpc_httpcli_request* request) {
gpr_strvec out;
gpr_strvec_init(&out);
gpr_strvec_add(&out, gpr_strdup("CONNECT "));
fill_common_header(request, &out, false);
gpr_strvec_add(&out, gpr_strdup("\r\n"));
size_t flat_len;
- char *flat = gpr_strvec_flatten(&out, &flat_len);
+ char* flat = gpr_strvec_flatten(&out, &flat_len);
gpr_strvec_destroy(&out);
return grpc_slice_new(flat, flat_len, gpr_free);
}
diff --git a/src/core/lib/http/format_request.h b/src/core/lib/http/format_request.h
index 2e77e8661a..32054805b4 100644
--- a/src/core/lib/http/format_request.h
+++ b/src/core/lib/http/format_request.h
@@ -26,12 +26,12 @@
extern "C" {
#endif
-grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request);
-grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
- const char *body_bytes,
+grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request* request);
+grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
+ const char* body_bytes,
size_t body_size);
grpc_slice grpc_httpcli_format_connect_request(
- const grpc_httpcli_request *request);
+ const grpc_httpcli_request* request);
#ifdef __cplusplus
}
diff --git a/src/core/lib/http/httpcli.cc b/src/core/lib/http/httpcli.cc
index c96800b85c..493e6af95c 100644
--- a/src/core/lib/http/httpcli.cc
+++ b/src/core/lib/http/httpcli.cc
@@ -39,56 +39,56 @@
typedef struct {
grpc_slice request_text;
grpc_http_parser parser;
- grpc_resolved_addresses *addresses;
+ grpc_resolved_addresses* addresses;
size_t next_address;
- grpc_endpoint *ep;
- char *host;
- char *ssl_host_override;
+ grpc_endpoint* ep;
+ char* host;
+ char* ssl_host_override;
grpc_millis deadline;
int have_read_byte;
- const grpc_httpcli_handshaker *handshaker;
- grpc_closure *on_done;
- grpc_httpcli_context *context;
- grpc_polling_entity *pollent;
+ const grpc_httpcli_handshaker* handshaker;
+ grpc_closure* on_done;
+ grpc_httpcli_context* context;
+ grpc_polling_entity* pollent;
grpc_iomgr_object iomgr_obj;
grpc_slice_buffer incoming;
grpc_slice_buffer outgoing;
grpc_closure on_read;
grpc_closure done_write;
grpc_closure connected;
- grpc_error *overall_error;
- grpc_resource_quota *resource_quota;
+ grpc_error* overall_error;
+ grpc_resource_quota* resource_quota;
} internal_request;
static grpc_httpcli_get_override g_get_override = NULL;
static grpc_httpcli_post_override g_post_override = NULL;
-static void plaintext_handshake(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *endpoint, const char *host,
+static void plaintext_handshake(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_endpoint* endpoint, const char* host,
grpc_millis deadline,
- void (*on_done)(grpc_exec_ctx *exec_ctx,
- void *arg,
- grpc_endpoint *endpoint)) {
+ void (*on_done)(grpc_exec_ctx* exec_ctx,
+ void* arg,
+ grpc_endpoint* endpoint)) {
on_done(exec_ctx, arg, endpoint);
}
const grpc_httpcli_handshaker grpc_httpcli_plaintext = {"http",
plaintext_handshake};
-void grpc_httpcli_context_init(grpc_httpcli_context *context) {
+void grpc_httpcli_context_init(grpc_httpcli_context* context) {
context->pollset_set = grpc_pollset_set_create();
}
-void grpc_httpcli_context_destroy(grpc_exec_ctx *exec_ctx,
- grpc_httpcli_context *context) {
+void grpc_httpcli_context_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_httpcli_context* context) {
grpc_pollset_set_destroy(exec_ctx, context->pollset_set);
}
-static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
- grpc_error *due_to_error);
+static void next_address(grpc_exec_ctx* exec_ctx, internal_request* req,
+ grpc_error* due_to_error);
-static void finish(grpc_exec_ctx *exec_ctx, internal_request *req,
- grpc_error *error) {
+static void finish(grpc_exec_ctx* exec_ctx, internal_request* req,
+ grpc_error* error) {
grpc_polling_entity_del_from_pollset_set(exec_ctx, req->pollent,
req->context->pollset_set);
GRPC_CLOSURE_SCHED(exec_ctx, req->on_done, error);
@@ -110,13 +110,13 @@ static void finish(grpc_exec_ctx *exec_ctx, internal_request *req,
gpr_free(req);
}
-static void append_error(internal_request *req, grpc_error *error) {
+static void append_error(internal_request* req, grpc_error* error) {
if (req->overall_error == GRPC_ERROR_NONE) {
req->overall_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request");
}
- grpc_resolved_address *addr = &req->addresses->addrs[req->next_address - 1];
- char *addr_text = grpc_sockaddr_to_uri(addr);
+ grpc_resolved_address* addr = &req->addresses->addrs[req->next_address - 1];
+ char* addr_text = grpc_sockaddr_to_uri(addr);
req->overall_error = grpc_error_add_child(
req->overall_error,
grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
@@ -124,19 +124,19 @@ static void append_error(internal_request *req, grpc_error *error) {
gpr_free(addr_text);
}
-static void do_read(grpc_exec_ctx *exec_ctx, internal_request *req) {
+static void do_read(grpc_exec_ctx* exec_ctx, internal_request* req) {
grpc_endpoint_read(exec_ctx, req->ep, &req->incoming, &req->on_read);
}
-static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_error *error) {
- internal_request *req = (internal_request *)user_data;
+static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
+ grpc_error* error) {
+ internal_request* req = (internal_request*)user_data;
size_t i;
for (i = 0; i < req->incoming.count; i++) {
if (GRPC_SLICE_LENGTH(req->incoming.slices[i])) {
req->have_read_byte = 1;
- grpc_error *err =
+ grpc_error* err =
grpc_http_parser_parse(&req->parser, req->incoming.slices[i], NULL);
if (err != GRPC_ERROR_NONE) {
finish(exec_ctx, req, err);
@@ -154,12 +154,12 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
}
}
-static void on_written(grpc_exec_ctx *exec_ctx, internal_request *req) {
+static void on_written(grpc_exec_ctx* exec_ctx, internal_request* req) {
do_read(exec_ctx, req);
}
-static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- internal_request *req = (internal_request *)arg;
+static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ internal_request* req = (internal_request*)arg;
if (error == GRPC_ERROR_NONE) {
on_written(exec_ctx, req);
} else {
@@ -167,19 +167,20 @@ static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
}
}
-static void start_write(grpc_exec_ctx *exec_ctx, internal_request *req) {
+static void start_write(grpc_exec_ctx* exec_ctx, internal_request* req) {
grpc_slice_ref_internal(req->request_text);
grpc_slice_buffer_add(&req->outgoing, req->request_text);
grpc_endpoint_write(exec_ctx, req->ep, &req->outgoing, &req->done_write);
}
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *ep) {
- internal_request *req = (internal_request *)arg;
+static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_endpoint* ep) {
+ internal_request* req = (internal_request*)arg;
if (!ep) {
- next_address(exec_ctx, req, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Unexplained handshake failure"));
+ next_address(
+ exec_ctx, req,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexplained handshake failure"));
return;
}
@@ -187,9 +188,9 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
start_write(exec_ctx, req);
}
-static void on_connected(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- internal_request *req = (internal_request *)arg;
+static void on_connected(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ internal_request* req = (internal_request*)arg;
if (!req->ep) {
next_address(exec_ctx, req, GRPC_ERROR_REF(error));
@@ -201,9 +202,9 @@ static void on_connected(grpc_exec_ctx *exec_ctx, void *arg,
req->deadline, on_handshake_done);
}
-static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
- grpc_error *error) {
- grpc_resolved_address *addr;
+static void next_address(grpc_exec_ctx* exec_ctx, internal_request* req,
+ grpc_error* error) {
+ grpc_resolved_address* addr;
if (error != GRPC_ERROR_NONE) {
append_error(req, error);
}
@@ -217,7 +218,7 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
GRPC_CLOSURE_INIT(&req->connected, on_connected, req,
grpc_schedule_on_exec_ctx);
grpc_arg arg = grpc_channel_arg_pointer_create(
- (char *)GRPC_ARG_RESOURCE_QUOTA, req->resource_quota,
+ (char*)GRPC_ARG_RESOURCE_QUOTA, req->resource_quota,
grpc_resource_quota_arg_vtable());
grpc_channel_args args = {1, &arg};
grpc_tcp_client_connect(exec_ctx, &req->connected, &req->ep,
@@ -225,8 +226,8 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
req->deadline);
}
-static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
- internal_request *req = (internal_request *)arg;
+static void on_resolved(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ internal_request* req = (internal_request*)arg;
if (error != GRPC_ERROR_NONE) {
finish(exec_ctx, req, GRPC_ERROR_REF(error));
return;
@@ -235,16 +236,16 @@ static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
next_address(exec_ctx, req, GRPC_ERROR_NONE);
}
-static void internal_request_begin(grpc_exec_ctx *exec_ctx,
- grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response,
- const char *name, grpc_slice request_text) {
- internal_request *req =
- (internal_request *)gpr_malloc(sizeof(internal_request));
+static void internal_request_begin(grpc_exec_ctx* exec_ctx,
+ grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response,
+ const char* name, grpc_slice request_text) {
+ internal_request* req =
+ (internal_request*)gpr_malloc(sizeof(internal_request));
memset(req, 0, sizeof(*req));
req->request_text = request_text;
grpc_http_parser_init(&req->parser, GRPC_HTTP_RESPONSE, response);
@@ -275,12 +276,12 @@ static void internal_request_begin(grpc_exec_ctx *exec_ctx,
&req->addresses);
}
-void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request, grpc_millis deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
- char *name;
+void grpc_httpcli_get(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
+ char* name;
if (g_get_override &&
g_get_override(exec_ctx, request, deadline, on_done, response)) {
return;
@@ -292,14 +293,14 @@ void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
gpr_free(name);
}
-void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
- char *name;
+void grpc_httpcli_post(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request,
+ const char* body_bytes, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
+ char* name;
if (g_post_override &&
g_post_override(exec_ctx, request, body_bytes, body_size, deadline,
on_done, response)) {
diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h
index 76b790fa8a..a3411341ad 100644
--- a/src/core/lib/http/httpcli.h
+++ b/src/core/lib/http/httpcli.h
@@ -40,15 +40,15 @@ extern "C" {
TODO(ctiller): allow caching and capturing multiple requests for the
same content and combining them */
typedef struct grpc_httpcli_context {
- grpc_pollset_set *pollset_set;
+ grpc_pollset_set* pollset_set;
} grpc_httpcli_context;
typedef struct {
- const char *default_port;
- void (*handshake)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint,
- const char *host, grpc_millis deadline,
- void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *endpoint));
+ const char* default_port;
+ void (*handshake)(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* endpoint,
+ const char* host, grpc_millis deadline,
+ void (*on_done)(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_endpoint* endpoint));
} grpc_httpcli_handshaker;
extern const grpc_httpcli_handshaker grpc_httpcli_plaintext;
@@ -57,23 +57,23 @@ extern const grpc_httpcli_handshaker grpc_httpcli_ssl;
/* A request */
typedef struct grpc_httpcli_request {
/* The host name to connect to */
- char *host;
+ char* host;
/* The host to verify in the SSL handshake (or NULL) */
- char *ssl_host_override;
+ char* ssl_host_override;
/* The main part of the request
The following headers are supplied automatically and MUST NOT be set here:
Host, Connection, User-Agent */
grpc_http_request http;
/* handshaker to use ssl for the request */
- const grpc_httpcli_handshaker *handshaker;
+ const grpc_httpcli_handshaker* handshaker;
} grpc_httpcli_request;
/* Expose the parser response type as a httpcli response too */
typedef struct grpc_http_response grpc_httpcli_response;
-void grpc_httpcli_context_init(grpc_httpcli_context *context);
-void grpc_httpcli_context_destroy(grpc_exec_ctx *exec_ctx,
- grpc_httpcli_context *context);
+void grpc_httpcli_context_init(grpc_httpcli_context* context);
+void grpc_httpcli_context_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_httpcli_context* context);
/* Asynchronously perform a HTTP GET.
'context' specifies the http context under which to do the get
@@ -84,12 +84,12 @@ void grpc_httpcli_context_destroy(grpc_exec_ctx *exec_ctx,
destroyed once the call returns
'deadline' contains a deadline for the request (or gpr_inf_future)
'on_response' is a callback to report results to */
-void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request, grpc_millis deadline,
- grpc_closure *on_complete,
- grpc_httpcli_response *response);
+void grpc_httpcli_get(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_complete,
+ grpc_httpcli_response* response);
/* Asynchronously perform a HTTP POST.
'context' specifies the http context under which to do the post
@@ -105,24 +105,24 @@ void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
lifetime of the request
'on_response' is a callback to report results to
Does not support ?var1=val1&var2=val2 in the path. */
-void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
- grpc_polling_entity *pollent,
- grpc_resource_quota *resource_quota,
- const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size,
- grpc_millis deadline, grpc_closure *on_complete,
- grpc_httpcli_response *response);
+void grpc_httpcli_post(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+ grpc_polling_entity* pollent,
+ grpc_resource_quota* resource_quota,
+ const grpc_httpcli_request* request,
+ const char* body_bytes, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_complete,
+ grpc_httpcli_response* response);
/* override functions return 1 if they handled the request, 0 otherwise */
-typedef int (*grpc_httpcli_get_override)(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
+typedef int (*grpc_httpcli_get_override)(grpc_exec_ctx* exec_ctx,
+ const grpc_httpcli_request* request,
grpc_millis deadline,
- grpc_closure *on_complete,
- grpc_httpcli_response *response);
+ grpc_closure* on_complete,
+ grpc_httpcli_response* response);
typedef int (*grpc_httpcli_post_override)(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure *on_complete, grpc_httpcli_response *response);
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ const char* body_bytes, size_t body_size, grpc_millis deadline,
+ grpc_closure* on_complete, grpc_httpcli_response* response);
void grpc_httpcli_set_override(grpc_httpcli_get_override get,
grpc_httpcli_post_override post);
diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc
index d832dacb69..d029323eac 100644
--- a/src/core/lib/http/httpcli_security_connector.cc
+++ b/src/core/lib/http/httpcli_security_connector.cc
@@ -34,14 +34,14 @@
typedef struct {
grpc_channel_security_connector base;
- tsi_ssl_client_handshaker_factory *handshaker_factory;
- char *secure_peer_name;
+ tsi_ssl_client_handshaker_factory* handshaker_factory;
+ char* secure_peer_name;
} grpc_httpcli_ssl_channel_security_connector;
-static void httpcli_ssl_destroy(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc) {
- grpc_httpcli_ssl_channel_security_connector *c =
- (grpc_httpcli_ssl_channel_security_connector *)sc;
+static void httpcli_ssl_destroy(grpc_exec_ctx* exec_ctx,
+ grpc_security_connector* sc) {
+ grpc_httpcli_ssl_channel_security_connector* c =
+ (grpc_httpcli_ssl_channel_security_connector*)sc;
if (c->handshaker_factory != NULL) {
tsi_ssl_client_handshaker_factory_unref(c->handshaker_factory);
c->handshaker_factory = NULL;
@@ -50,12 +50,12 @@ static void httpcli_ssl_destroy(grpc_exec_ctx *exec_ctx,
gpr_free(sc);
}
-static void httpcli_ssl_add_handshakers(grpc_exec_ctx *exec_ctx,
- grpc_channel_security_connector *sc,
- grpc_handshake_manager *handshake_mgr) {
- grpc_httpcli_ssl_channel_security_connector *c =
- (grpc_httpcli_ssl_channel_security_connector *)sc;
- tsi_handshaker *handshaker = NULL;
+static void httpcli_ssl_add_handshakers(grpc_exec_ctx* exec_ctx,
+ grpc_channel_security_connector* sc,
+ grpc_handshake_manager* handshake_mgr) {
+ grpc_httpcli_ssl_channel_security_connector* c =
+ (grpc_httpcli_ssl_channel_security_connector*)sc;
+ tsi_handshaker* handshaker = NULL;
if (c->handshaker_factory != NULL) {
tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
c->handshaker_factory, c->secure_peer_name, &handshaker);
@@ -70,18 +70,18 @@ static void httpcli_ssl_add_handshakers(grpc_exec_ctx *exec_ctx,
exec_ctx, tsi_create_adapter_handshaker(handshaker), &sc->base));
}
-static void httpcli_ssl_check_peer(grpc_exec_ctx *exec_ctx,
- grpc_security_connector *sc, tsi_peer peer,
- grpc_auth_context **auth_context,
- grpc_closure *on_peer_checked) {
- grpc_httpcli_ssl_channel_security_connector *c =
- (grpc_httpcli_ssl_channel_security_connector *)sc;
- grpc_error *error = GRPC_ERROR_NONE;
+static void httpcli_ssl_check_peer(grpc_exec_ctx* exec_ctx,
+ grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
+ grpc_closure* on_peer_checked) {
+ grpc_httpcli_ssl_channel_security_connector* c =
+ (grpc_httpcli_ssl_channel_security_connector*)sc;
+ grpc_error* error = GRPC_ERROR_NONE;
/* Check the peer name. */
if (c->secure_peer_name != NULL &&
!tsi_ssl_peer_matches_name(&peer, c->secure_peer_name)) {
- char *msg;
+ char* msg;
gpr_asprintf(&msg, "Peer name %s is not in peer certificate",
c->secure_peer_name);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
@@ -91,12 +91,12 @@ static void httpcli_ssl_check_peer(grpc_exec_ctx *exec_ctx,
tsi_peer_destruct(&peer);
}
-static int httpcli_ssl_cmp(grpc_security_connector *sc1,
- grpc_security_connector *sc2) {
- grpc_httpcli_ssl_channel_security_connector *c1 =
- (grpc_httpcli_ssl_channel_security_connector *)sc1;
- grpc_httpcli_ssl_channel_security_connector *c2 =
- (grpc_httpcli_ssl_channel_security_connector *)sc2;
+static int httpcli_ssl_cmp(grpc_security_connector* sc1,
+ grpc_security_connector* sc2) {
+ grpc_httpcli_ssl_channel_security_connector* c1 =
+ (grpc_httpcli_ssl_channel_security_connector*)sc1;
+ grpc_httpcli_ssl_channel_security_connector* c2 =
+ (grpc_httpcli_ssl_channel_security_connector*)sc2;
return strcmp(c1->secure_peer_name, c2->secure_peer_name);
}
@@ -104,10 +104,10 @@ static grpc_security_connector_vtable httpcli_ssl_vtable = {
httpcli_ssl_destroy, httpcli_ssl_check_peer, httpcli_ssl_cmp};
static grpc_security_status httpcli_ssl_channel_security_connector_create(
- grpc_exec_ctx *exec_ctx, const char *pem_root_certs,
- const char *secure_peer_name, grpc_channel_security_connector **sc) {
+ grpc_exec_ctx* exec_ctx, const char* pem_root_certs,
+ const char* secure_peer_name, grpc_channel_security_connector** sc) {
tsi_result result = TSI_OK;
- grpc_httpcli_ssl_channel_security_connector *c;
+ grpc_httpcli_ssl_channel_security_connector* c;
if (secure_peer_name != NULL && pem_root_certs == NULL) {
gpr_log(GPR_ERROR,
@@ -115,7 +115,7 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
return GRPC_SECURITY_ERROR;
}
- c = (grpc_httpcli_ssl_channel_security_connector *)gpr_zalloc(
+ c = (grpc_httpcli_ssl_channel_security_connector*)gpr_zalloc(
sizeof(grpc_httpcli_ssl_channel_security_connector));
gpr_ref_init(&c->base.base.refcount, 1);
@@ -135,7 +135,7 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
// We don't actually need a channel credentials object in this case,
// but we set it to a non-NULL address so that we don't trigger
// assertions in grpc_channel_security_connector_cmp().
- c->base.channel_creds = (grpc_channel_credentials *)1;
+ c->base.channel_creds = (grpc_channel_credentials*)1;
c->base.add_handshakers = httpcli_ssl_add_handshakers;
*sc = &c->base;
return GRPC_SECURITY_OK;
@@ -144,17 +144,17 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
/* handshaker */
typedef struct {
- void (*func)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint);
- void *arg;
- grpc_handshake_manager *handshake_mgr;
+ void (*func)(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* endpoint);
+ void* arg;
+ grpc_handshake_manager* handshake_mgr;
} on_done_closure;
-static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- grpc_handshaker_args *args = (grpc_handshaker_args *)arg;
- on_done_closure *c = (on_done_closure *)args->user_data;
+static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
+ on_done_closure* c = (on_done_closure*)args->user_data;
if (error != GRPC_ERROR_NONE) {
- const char *msg = grpc_error_string(error);
+ const char* msg = grpc_error_string(error);
gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg);
c->func(exec_ctx, c->arg, NULL);
@@ -168,13 +168,13 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
gpr_free(c);
}
-static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *tcp, const char *host,
+static void ssl_handshake(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_endpoint* tcp, const char* host,
grpc_millis deadline,
- void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_endpoint *endpoint)) {
- on_done_closure *c = (on_done_closure *)gpr_malloc(sizeof(*c));
- const char *pem_root_certs = grpc_get_default_ssl_roots();
+ void (*on_done)(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_endpoint* endpoint)) {
+ on_done_closure* c = (on_done_closure*)gpr_malloc(sizeof(*c));
+ const char* pem_root_certs = grpc_get_default_ssl_roots();
if (pem_root_certs == NULL) {
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
on_done(exec_ctx, arg, NULL);
@@ -183,7 +183,7 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
}
c->func = on_done;
c->arg = arg;
- grpc_channel_security_connector *sc = NULL;
+ grpc_channel_security_connector* sc = NULL;
GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
exec_ctx, pem_root_certs, host, &sc) == GRPC_SECURITY_OK);
grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base);
diff --git a/src/core/lib/http/parser.cc b/src/core/lib/http/parser.cc
index 0950bd655e..99a4919401 100644
--- a/src/core/lib/http/parser.cc
+++ b/src/core/lib/http/parser.cc
@@ -27,17 +27,17 @@
grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false, "http1");
-static char *buf2str(void *buffer, size_t length) {
- char *out = (char *)gpr_malloc(length + 1);
+static char* buf2str(void* buffer, size_t length) {
+ char* out = (char*)gpr_malloc(length + 1);
memcpy(out, buffer, length);
out[length] = 0;
return out;
}
-static grpc_error *handle_response_line(grpc_http_parser *parser) {
- uint8_t *beg = parser->cur_line;
- uint8_t *cur = beg;
- uint8_t *end = beg + parser->cur_line_length;
+static grpc_error* handle_response_line(grpc_http_parser* parser) {
+ uint8_t* beg = parser->cur_line;
+ uint8_t* cur = beg;
+ uint8_t* end = beg + parser->cur_line_length;
if (cur == end || *cur++ != 'H')
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Expected 'H'");
@@ -75,10 +75,10 @@ static grpc_error *handle_response_line(grpc_http_parser *parser) {
return GRPC_ERROR_NONE;
}
-static grpc_error *handle_request_line(grpc_http_parser *parser) {
- uint8_t *beg = parser->cur_line;
- uint8_t *cur = beg;
- uint8_t *end = beg + parser->cur_line_length;
+static grpc_error* handle_request_line(grpc_http_parser* parser) {
+ uint8_t* beg = parser->cur_line;
+ uint8_t* cur = beg;
+ uint8_t* end = beg + parser->cur_line_length;
uint8_t vers_major = 0;
uint8_t vers_minor = 0;
@@ -137,7 +137,7 @@ static grpc_error *handle_request_line(grpc_http_parser *parser) {
return GRPC_ERROR_NONE;
}
-static grpc_error *handle_first_line(grpc_http_parser *parser) {
+static grpc_error* handle_first_line(grpc_http_parser* parser) {
switch (parser->type) {
case GRPC_HTTP_REQUEST:
return handle_request_line(parser);
@@ -148,14 +148,14 @@ static grpc_error *handle_first_line(grpc_http_parser *parser) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here"));
}
-static grpc_error *add_header(grpc_http_parser *parser) {
- uint8_t *beg = parser->cur_line;
- uint8_t *cur = beg;
- uint8_t *end = beg + parser->cur_line_length;
- size_t *hdr_count = NULL;
- grpc_http_header **hdrs = NULL;
+static grpc_error* add_header(grpc_http_parser* parser) {
+ uint8_t* beg = parser->cur_line;
+ uint8_t* cur = beg;
+ uint8_t* end = beg + parser->cur_line_length;
+ size_t* hdr_count = NULL;
+ grpc_http_header** hdrs = NULL;
grpc_http_header hdr = {NULL, NULL};
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
GPR_ASSERT(cur != end);
@@ -197,7 +197,7 @@ static grpc_error *add_header(grpc_http_parser *parser) {
if (*hdr_count == parser->hdr_capacity) {
parser->hdr_capacity =
GPR_MAX(parser->hdr_capacity + 1, parser->hdr_capacity * 3 / 2);
- *hdrs = (grpc_http_header *)gpr_realloc(
+ *hdrs = (grpc_http_header*)gpr_realloc(
*hdrs, parser->hdr_capacity * sizeof(**hdrs));
}
(*hdrs)[(*hdr_count)++] = hdr;
@@ -210,9 +210,9 @@ done:
return error;
}
-static grpc_error *finish_line(grpc_http_parser *parser,
- bool *found_body_start) {
- grpc_error *err;
+static grpc_error* finish_line(grpc_http_parser* parser,
+ bool* found_body_start) {
+ grpc_error* err;
switch (parser->state) {
case GRPC_HTTP_FIRST_LINE:
err = handle_first_line(parser);
@@ -239,9 +239,9 @@ static grpc_error *finish_line(grpc_http_parser *parser,
return GRPC_ERROR_NONE;
}
-static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
- size_t *body_length = NULL;
- char **body = NULL;
+static grpc_error* addbyte_body(grpc_http_parser* parser, uint8_t byte) {
+ size_t* body_length = NULL;
+ char** body = NULL;
if (parser->type == GRPC_HTTP_RESPONSE) {
body_length = &parser->http.response->body_length;
@@ -256,7 +256,7 @@ static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
if (*body_length == parser->body_capacity) {
parser->body_capacity = GPR_MAX(8, parser->body_capacity * 3 / 2);
- *body = (char *)gpr_realloc((void *)*body, parser->body_capacity);
+ *body = (char*)gpr_realloc((void*)*body, parser->body_capacity);
}
(*body)[*body_length] = (char)byte;
(*body_length)++;
@@ -264,7 +264,7 @@ static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
return GRPC_ERROR_NONE;
}
-static bool check_line(grpc_http_parser *parser) {
+static bool check_line(grpc_http_parser* parser) {
if (parser->cur_line_length >= 2 &&
parser->cur_line[parser->cur_line_length - 2] == '\r' &&
parser->cur_line[parser->cur_line_length - 1] == '\n') {
@@ -288,8 +288,8 @@ static bool check_line(grpc_http_parser *parser) {
return false;
}
-static grpc_error *addbyte(grpc_http_parser *parser, uint8_t byte,
- bool *found_body_start) {
+static grpc_error* addbyte(grpc_http_parser* parser, uint8_t byte,
+ bool* found_body_start) {
switch (parser->state) {
case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS:
@@ -312,8 +312,8 @@ static grpc_error *addbyte(grpc_http_parser *parser, uint8_t byte,
GPR_UNREACHABLE_CODE(return GRPC_ERROR_NONE);
}
-void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type,
- void *request_or_response) {
+void grpc_http_parser_init(grpc_http_parser* parser, grpc_http_type type,
+ void* request_or_response) {
memset(parser, 0, sizeof(*parser));
parser->state = GRPC_HTTP_FIRST_LINE;
parser->type = type;
@@ -321,9 +321,9 @@ void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type,
parser->cur_line_end_length = 2;
}
-void grpc_http_parser_destroy(grpc_http_parser *parser) {}
+void grpc_http_parser_destroy(grpc_http_parser* parser) {}
-void grpc_http_request_destroy(grpc_http_request *request) {
+void grpc_http_request_destroy(grpc_http_request* request) {
size_t i;
gpr_free(request->body);
for (i = 0; i < request->hdr_count; i++) {
@@ -335,7 +335,7 @@ void grpc_http_request_destroy(grpc_http_request *request) {
gpr_free(request->path);
}
-void grpc_http_response_destroy(grpc_http_response *response) {
+void grpc_http_response_destroy(grpc_http_response* response) {
size_t i;
gpr_free(response->body);
for (i = 0; i < response->hdr_count; i++) {
@@ -345,11 +345,11 @@ void grpc_http_response_destroy(grpc_http_response *response) {
gpr_free(response->hdrs);
}
-grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice,
- size_t *start_of_body) {
+grpc_error* grpc_http_parser_parse(grpc_http_parser* parser, grpc_slice slice,
+ size_t* start_of_body) {
for (size_t i = 0; i < GRPC_SLICE_LENGTH(slice); i++) {
bool found_body_start = false;
- grpc_error *err =
+ grpc_error* err =
addbyte(parser, GRPC_SLICE_START_PTR(slice)[i], &found_body_start);
if (err != GRPC_ERROR_NONE) return err;
if (found_body_start && start_of_body != NULL) *start_of_body = i + 1;
@@ -357,7 +357,7 @@ grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice,
return GRPC_ERROR_NONE;
}
-grpc_error *grpc_http_parser_eof(grpc_http_parser *parser) {
+grpc_error* grpc_http_parser_eof(grpc_http_parser* parser) {
if (parser->state != GRPC_HTTP_BODY) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Did not finish headers");
}
diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h
index d2bda6ae0e..3d28481c4c 100644
--- a/src/core/lib/http/parser.h
+++ b/src/core/lib/http/parser.h
@@ -33,8 +33,8 @@ extern "C" {
/* A single header to be passed in a request */
typedef struct grpc_http_header {
- char *key;
- char *value;
+ char* key;
+ char* value;
} grpc_http_header;
typedef enum {
@@ -57,17 +57,17 @@ typedef enum {
/* A request */
typedef struct grpc_http_request {
/* Method of the request (e.g. GET, POST) */
- char *method;
+ char* method;
/* The path of the resource to fetch */
- char *path;
+ char* path;
/* HTTP version to use */
grpc_http_version version;
/* Headers attached to the request */
size_t hdr_count;
- grpc_http_header *hdrs;
+ grpc_http_header* hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
- char *body;
+ char* body;
} grpc_http_request;
/* A response */
@@ -76,10 +76,10 @@ typedef struct grpc_http_response {
int status;
/* Headers: count and key/values */
size_t hdr_count;
- grpc_http_header *hdrs;
+ grpc_http_header* hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
- char *body;
+ char* body;
} grpc_http_response;
typedef struct {
@@ -87,9 +87,9 @@ typedef struct {
grpc_http_type type;
union {
- grpc_http_response *response;
- grpc_http_request *request;
- void *request_or_response;
+ grpc_http_response* response;
+ grpc_http_request* request;
+ void* request_or_response;
} http;
size_t body_capacity;
size_t hdr_capacity;
@@ -99,17 +99,17 @@ typedef struct {
size_t cur_line_end_length;
} grpc_http_parser;
-void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type,
- void *request_or_response);
-void grpc_http_parser_destroy(grpc_http_parser *parser);
+void grpc_http_parser_init(grpc_http_parser* parser, grpc_http_type type,
+ void* request_or_response);
+void grpc_http_parser_destroy(grpc_http_parser* parser);
/* Sets \a start_of_body to the offset in \a slice of the start of the body. */
-grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice,
- size_t *start_of_body);
-grpc_error *grpc_http_parser_eof(grpc_http_parser *parser);
+grpc_error* grpc_http_parser_parse(grpc_http_parser* parser, grpc_slice slice,
+ size_t* start_of_body);
+grpc_error* grpc_http_parser_eof(grpc_http_parser* parser);
-void grpc_http_request_destroy(grpc_http_request *request);
-void grpc_http_response_destroy(grpc_http_response *response);
+void grpc_http_request_destroy(grpc_http_request* request);
+void grpc_http_response_destroy(grpc_http_response* response);
extern grpc_tracer_flag grpc_http1_trace;