From c06e76f6fe0da2c9d06f15b6a57af78155c43149 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 14 Jun 2014 00:11:01 +0200 Subject: http2: better return code error checking --- lib/http.c | 12 ++++++++++-- lib/http2.c | 13 +++++++++---- lib/http2.h | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/http.c b/lib/http.c index 5711ee64b..3cf7346d8 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1749,8 +1749,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) http2 */ switch (conn->negnpn) { case NPN_HTTP2: - Curl_http2_init(conn); - Curl_http2_setup(conn); + result = Curl_http2_init(conn); + if(result) + return result; + + result = Curl_http2_setup(conn); + if(result) + return result; + + /* TODO: add error checking here */ Curl_http2_switched(conn); break; case NPN_HTTP1_1: @@ -2997,6 +3004,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, k->upgr101 = UPGR101_RECEIVED; /* switch to http2 now */ + /* TODO: add error checking */ Curl_http2_switched(conn); } break; diff --git a/lib/http2.c b/lib/http2.c index 7fc8bd94f..c850fdb8f 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -481,8 +481,13 @@ CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req, struct SingleRequest *k = &conn->data->req; uint8_t *binsettings = conn->proto.httpc.binsettings; - Curl_http2_init(conn); - Curl_http2_setup(conn); + result = Curl_http2_init(conn); + if(result) + return result; + + result = Curl_http2_setup(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, @@ -779,7 +784,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, return len; } -void Curl_http2_setup(struct connectdata *conn) +CURLcode Curl_http2_setup(struct connectdata *conn) { struct http_conn *httpc = &conn->proto.httpc; if(conn->handler->flags & PROTOPT_SSL) @@ -802,7 +807,7 @@ void Curl_http2_setup(struct connectdata *conn) conn->httpversion = 20; /* Put place holder for status line */ - Curl_add_buffer(httpc->header_recvbuf, "HTTP/2.0 200\r\n", 14); + return Curl_add_buffer(httpc->header_recvbuf, "HTTP/2.0 200\r\n", 14); } int Curl_http2_switched(struct connectdata *conn) diff --git a/lib/http2.h b/lib/http2.h index ee95ef656..30a8b591b 100644 --- a/lib/http2.h +++ b/lib/http2.h @@ -36,7 +36,7 @@ CURLcode Curl_http2_init(struct connectdata *conn); CURLcode Curl_http2_send_request(struct connectdata *conn); CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req, struct connectdata *conn); -void Curl_http2_setup(struct connectdata *conn); +CURLcode Curl_http2_setup(struct connectdata *conn); int Curl_http2_switched(struct connectdata *conn); #else /* USE_NGHTTP2 */ #define Curl_http2_init(x) -- cgit v1.2.3