diff options
Diffstat (limited to 'src/core/httpcli/httpcli.h')
-rw-r--r-- | src/core/httpcli/httpcli.h | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/src/core/httpcli/httpcli.h b/src/core/httpcli/httpcli.h index 9c489721b6..6469c2f03e 100644 --- a/src/core/httpcli/httpcli.h +++ b/src/core/httpcli/httpcli.h @@ -47,8 +47,7 @@ #define GRPC_HTTPCLI_MAX_HEADER_LENGTH 4096 /* A single header to be passed in a request */ -typedef struct grpc_httpcli_header -{ +typedef struct grpc_httpcli_header { char *key; char *value; } grpc_httpcli_header; @@ -56,23 +55,23 @@ typedef struct grpc_httpcli_header /* Tracks in-progress http requests TODO(ctiller): allow caching and capturing multiple requests for the same content and combining them */ -typedef struct grpc_httpcli_context -{ +typedef struct grpc_httpcli_context { grpc_pollset_set pollset_set; } grpc_httpcli_context; -typedef struct -{ +typedef struct { const char *default_port; - void (*handshake) (grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint * endpoint, const char *host, void (*on_done) (grpc_exec_ctx * exec_ctx, void *arg, grpc_endpoint * endpoint)); + void (*handshake)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint, + const char *host, + void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg, + grpc_endpoint *endpoint)); } grpc_httpcli_handshaker; extern const grpc_httpcli_handshaker grpc_httpcli_plaintext; extern const grpc_httpcli_handshaker grpc_httpcli_ssl; /* A request */ -typedef struct grpc_httpcli_request -{ +typedef struct grpc_httpcli_request { /* The host name to connect to */ char *host; /* The path of the resource to fetch */ @@ -87,8 +86,7 @@ typedef struct grpc_httpcli_request } grpc_httpcli_request; /* A response */ -typedef struct grpc_httpcli_response -{ +typedef struct grpc_httpcli_response { /* HTTP status code */ int status; /* Headers: count and key/values */ @@ -100,10 +98,12 @@ typedef struct grpc_httpcli_response } grpc_httpcli_response; /* Callback for grpc_httpcli_get and grpc_httpcli_post. */ -typedef void (*grpc_httpcli_response_cb) (grpc_exec_ctx * exec_ctx, void *user_data, const grpc_httpcli_response * response); +typedef void (*grpc_httpcli_response_cb)(grpc_exec_ctx *exec_ctx, + void *user_data, + const grpc_httpcli_response *response); -void grpc_httpcli_context_init (grpc_httpcli_context * context); -void grpc_httpcli_context_destroy (grpc_httpcli_context * context); +void grpc_httpcli_context_init(grpc_httpcli_context *context); +void grpc_httpcli_context_destroy(grpc_httpcli_context *context); /* Asynchronously perform a HTTP GET. 'context' specifies the http context under which to do the get @@ -115,7 +115,11 @@ void grpc_httpcli_context_destroy (grpc_httpcli_context * context); 'deadline' contains a deadline for the request (or gpr_inf_future) 'on_response' is a callback to report results to (and 'user_data' is a user supplied pointer to pass to said call) */ -void grpc_httpcli_get (grpc_exec_ctx * exec_ctx, grpc_httpcli_context * context, grpc_pollset * pollset, const grpc_httpcli_request * request, gpr_timespec deadline, grpc_httpcli_response_cb on_response, void *user_data); +void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context, + grpc_pollset *pollset, + const grpc_httpcli_request *request, + gpr_timespec deadline, + grpc_httpcli_response_cb on_response, void *user_data); /* Asynchronously perform a HTTP POST. 'context' specifies the http context under which to do the post @@ -132,12 +136,25 @@ void grpc_httpcli_get (grpc_exec_ctx * exec_ctx, grpc_httpcli_context * context, 'on_response' is a callback to report results to (and 'user_data' is a user supplied pointer to pass to said call) Does not support ?var1=val1&var2=val2 in the path. */ -void grpc_httpcli_post (grpc_exec_ctx * exec_ctx, grpc_httpcli_context * context, grpc_pollset * pollset, const grpc_httpcli_request * request, const char *body_bytes, size_t body_size, gpr_timespec deadline, grpc_httpcli_response_cb on_response, void *user_data); +void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context, + grpc_pollset *pollset, + const grpc_httpcli_request *request, + const char *body_bytes, size_t body_size, + gpr_timespec deadline, + grpc_httpcli_response_cb on_response, void *user_data); /* 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, gpr_timespec deadline, grpc_httpcli_response_cb on_response, void *user_data); -typedef int (*grpc_httpcli_post_override) (grpc_exec_ctx * exec_ctx, const grpc_httpcli_request * request, const char *body_bytes, size_t body_size, gpr_timespec deadline, grpc_httpcli_response_cb on_response, void *user_data); - -void grpc_httpcli_set_override (grpc_httpcli_get_override get, grpc_httpcli_post_override post); +typedef int (*grpc_httpcli_get_override)(grpc_exec_ctx *exec_ctx, + const grpc_httpcli_request *request, + gpr_timespec deadline, + grpc_httpcli_response_cb on_response, + void *user_data); +typedef int (*grpc_httpcli_post_override)( + grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, + const char *body_bytes, size_t body_size, gpr_timespec deadline, + grpc_httpcli_response_cb on_response, void *user_data); + +void grpc_httpcli_set_override(grpc_httpcli_get_override get, + grpc_httpcli_post_override post); #endif /* GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_H */ |