Skip to content

Commit

Permalink
http2: move the init too for when its actually needed
Browse files Browse the repository at this point in the history
... it would otherwise lead to memory leakage if we never actually do
the switch.
  • Loading branch information
bagder committed Mar 23, 2015
1 parent 145c469 commit 4b02b84
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/http2.c
Expand Up @@ -636,10 +636,6 @@ CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req,
struct SingleRequest *k = &conn->data->req;
uint8_t *binsettings = conn->proto.httpc.binsettings;

result = Curl_http2_init(conn);
if(result)
return result;

/* As long as we have a fixed set of settings, we don't have to dynamically
* figure out the base64 strings since it'll always be the same. However,
* the settings will likely not be fixed every time in the future.
Expand Down Expand Up @@ -974,12 +970,17 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,

CURLcode Curl_http2_setup(struct connectdata *conn)
{
CURLcode result;
struct http_conn *httpc = &conn->proto.httpc;
if(conn->handler->flags & PROTOPT_SSL)
conn->handler = &Curl_handler_http2_ssl;
else
conn->handler = &Curl_handler_http2;

result = Curl_http2_init(conn);
if(result)
return result;

infof(conn->data, "Using HTTP2\n");
httpc->bodystarted = FALSE;
httpc->error_code = NGHTTP2_NO_ERROR;
Expand All @@ -996,7 +997,7 @@ CURLcode Curl_http2_setup(struct connectdata *conn)

conn->httpversion = 20;

return 0;
return CURLE_OK;
}

CURLcode Curl_http2_switched(struct connectdata *conn,
Expand Down

0 comments on commit 4b02b84

Please sign in to comment.