修改key_keeper请求为post
修改key_keeper请求连接为长连接 修改HTTP2流id设置时机
This commit is contained in:
@@ -42,9 +42,6 @@ int read_header_done_cb(struct evhttp_request* response, void* arg)
|
||||
|
||||
static void tfe_rpc_promise_free_ctx(void* ctx)
|
||||
{
|
||||
struct tfe_rpc_ctx* _ctx=(struct tfe_rpc_ctx*)ctx;
|
||||
evhttp_connection_free(_ctx->connection);
|
||||
_ctx->connection=NULL;
|
||||
free(ctx);
|
||||
ctx = NULL;
|
||||
return;
|
||||
@@ -182,7 +179,7 @@ char* get_request_url(struct evhttp_uri* uri, size_t url_len)
|
||||
}
|
||||
|
||||
//data is for POST. if method is GET, data should be NULL
|
||||
void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD method, enum TFE_RPC_FLAG flag, const char* data, int data_len, struct event_base * evbase, struct evdns_base* dnsbase)
|
||||
void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD method, enum TFE_RPC_FLAG flag, char* data, int data_len, struct event_base * evbase, struct evdns_base* dnsbase, struct evhttp_connection *evhttp)
|
||||
{
|
||||
const char* host=NULL;
|
||||
int port=0;
|
||||
@@ -211,14 +208,14 @@ void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD me
|
||||
if(port < 0)
|
||||
{
|
||||
port = 80;
|
||||
}
|
||||
|
||||
ctx->connection = evhttp_connection_base_new(evbase, dnsbase, host, port);
|
||||
}
|
||||
ctx->connection = evhttp;
|
||||
if (!ctx->connection)
|
||||
{
|
||||
_wrapped_promise_failed(p, FUTURE_ERROR_EXCEPTION, "create connection failed!");
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
evhttp_connection_set_closecb(ctx->connection, connection_close_cb, evbase);
|
||||
request = evhttp_request_new(get_response_cb, (void*)p);
|
||||
//evhttp_request_set_header_cb(request, read_header_done_cb);
|
||||
@@ -228,6 +225,7 @@ void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD me
|
||||
}
|
||||
evhttp_request_set_error_cb(request, request_error_cb);
|
||||
evhttp_add_header(evhttp_request_get_output_headers(request), "Host", host);
|
||||
evhttp_add_header(evhttp_request_get_output_headers(request), "Connection", "keep-alive");
|
||||
url_len = strlen(url);
|
||||
request_url = get_request_url(uri, url_len);
|
||||
//printf("request url is %s\n", request_url);
|
||||
@@ -249,12 +247,14 @@ void tfe_rpc_async_ask(struct future* f, const char* url, enum TFE_RPC_METHOD me
|
||||
_wrapped_promise_failed(p, FUTURE_ERROR_EXCEPTION, "method is invalid!");
|
||||
goto error_out;
|
||||
}
|
||||
free(data);
|
||||
free(request_url);
|
||||
evhttp_uri_free(uri);
|
||||
return;
|
||||
|
||||
error_out:
|
||||
if(uri) evhttp_uri_free(uri);
|
||||
if(data) free(data);
|
||||
promise_dettach_ctx(p);
|
||||
tfe_rpc_promise_free_ctx(ctx);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user