From 7b7f0da4a7397c918308bf9acb831d4a1d1a9583 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 13 Nov 2014 02:07:24 +0900 Subject: http2: Deal with HTTP/2 data inside response header buffer Previously if HTTP/2 traffic is appended to HTTP Upgrade response header (thus they are in the same buffer), the trailing HTTP/2 traffic is not processed and lost. The appended data is most likely SETTINGS frame. If it is lost, nghttp2 library complains server does not obey the HTTP/2 protocol and issues GOAWAY frame and curl eventually drops connection. This commit fixes this problem and now trailing data is processed. --- lib/http2.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/http2.c') diff --git a/lib/http2.c b/lib/http2.c index f86d3ebff..610c9c53a 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -988,7 +988,8 @@ CURLcode Curl_http2_setup(struct connectdata *conn) return 0; } -CURLcode Curl_http2_switched(struct connectdata *conn) +CURLcode Curl_http2_switched(struct connectdata *conn, + const char *mem, size_t nread) { CURLcode rc; struct http_conn *httpc = &conn->proto.httpc; @@ -1036,6 +1037,15 @@ CURLcode Curl_http2_switched(struct connectdata *conn) return CURLE_HTTP2; } } + + rv = (int)nghttp2_session_mem_recv(httpc->h2, (const uint8_t*)mem, nread); + + if(rv != (int)nread) { + failf(data, "nghttp2_session_mem_recv() failed: %s(%d)", + nghttp2_strerror(rv), rv); + return CURLE_HTTP2; + } + return CURLE_OK; } -- cgit v1.2.3