|
|
|
@ -542,7 +542,8 @@ static void create_grpc_frame(gpr_slice_buffer *write_slice_buffer, |
|
|
|
|
*/ |
|
|
|
|
static void convert_metadata_to_cronet_headers( |
|
|
|
|
grpc_linked_mdelem *head, const char *host, char **pp_url, |
|
|
|
|
cronet_bidirectional_stream_header **pp_headers, size_t *p_num_headers) { |
|
|
|
|
cronet_bidirectional_stream_header **pp_headers, size_t *p_num_headers, |
|
|
|
|
const char ** method) { |
|
|
|
|
grpc_linked_mdelem *curr = head; |
|
|
|
|
/* Walk the linked list and get number of header fields */ |
|
|
|
|
size_t num_headers_available = 0; |
|
|
|
@ -569,11 +570,20 @@ static void convert_metadata_to_cronet_headers( |
|
|
|
|
curr = curr->next; |
|
|
|
|
const char *key = grpc_mdstr_as_c_string(mdelem->key); |
|
|
|
|
const char *value = grpc_mdstr_as_c_string(mdelem->value); |
|
|
|
|
if (mdelem->key == GRPC_MDSTR_METHOD || mdelem->key == GRPC_MDSTR_SCHEME || |
|
|
|
|
if (mdelem->key == GRPC_MDSTR_SCHEME || |
|
|
|
|
mdelem->key == GRPC_MDSTR_AUTHORITY) { |
|
|
|
|
/* Cronet populates these fields on its own */ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (mdelem->key == GRPC_MDSTR_METHOD) { |
|
|
|
|
if (mdelem->value == GRPC_MDSTR_PUT) { |
|
|
|
|
*method = "PUT"; |
|
|
|
|
} else { |
|
|
|
|
/* POST method in default*/ |
|
|
|
|
*method = "POST"; |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (mdelem->key == GRPC_MDSTR_PATH) { |
|
|
|
|
/* Create URL by appending :path value to the hostname */ |
|
|
|
|
gpr_asprintf(pp_url, "https://%s%s", host, value); |
|
|
|
@ -771,14 +781,15 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, |
|
|
|
|
&cronet_callbacks); |
|
|
|
|
CRONET_LOG(GPR_DEBUG, "%p = cronet_bidirectional_stream_create()", s->cbs); |
|
|
|
|
char *url; |
|
|
|
|
const char *method; |
|
|
|
|
s->header_array.headers = NULL; |
|
|
|
|
convert_metadata_to_cronet_headers( |
|
|
|
|
stream_op->send_initial_metadata->list.head, s->curr_ct.host, &url, |
|
|
|
|
&s->header_array.headers, &s->header_array.count); |
|
|
|
|
&s->header_array.headers, &s->header_array.count, &method); |
|
|
|
|
s->header_array.capacity = s->header_array.count; |
|
|
|
|
CRONET_LOG(GPR_DEBUG, "cronet_bidirectional_stream_start(%p, %s)", s->cbs, |
|
|
|
|
url); |
|
|
|
|
cronet_bidirectional_stream_start(s->cbs, url, 0, "POST", &s->header_array, |
|
|
|
|
cronet_bidirectional_stream_start(s->cbs, url, 0, method, &s->header_array, |
|
|
|
|
false); |
|
|
|
|
stream_state->state_op_done[OP_SEND_INITIAL_METADATA] = true; |
|
|
|
|
result = ACTION_TAKEN_WITH_CALLBACK; |
|
|
|
|