aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/http.c8
-rw-r--r--lib/http2.c12
-rw-r--r--lib/http2.h3
3 files changed, 18 insertions, 5 deletions
diff --git a/lib/http.c b/lib/http.c
index 2487bac08..9083337c3 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1746,7 +1746,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(result)
return result;
- result = Curl_http2_switched(conn);
+ result = Curl_http2_switched(conn, NULL, 0);
if(result)
return result;
break;
@@ -2993,10 +2993,12 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
infof(data, "Received 101\n");
k->upgr101 = UPGR101_RECEIVED;
- /* switch to http2 now */
- result = Curl_http2_switched(conn);
+ /* switch to http2 now. The bytes after response headers
+ are also processed here, otherwise they are lost. */
+ result = Curl_http2_switched(conn, k->str, *nread);
if(result)
return result;
+ *nread = 0;
}
break;
default:
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;
}
diff --git a/lib/http2.h b/lib/http2.h
index 66aa6fd5c..5218957f5 100644
--- a/lib/http2.h
+++ b/lib/http2.h
@@ -37,7 +37,8 @@ CURLcode Curl_http2_send_request(struct connectdata *conn);
CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req,
struct connectdata *conn);
CURLcode Curl_http2_setup(struct connectdata *conn);
-CURLcode Curl_http2_switched(struct connectdata *conn);
+CURLcode Curl_http2_switched(struct connectdata *conn,
+ const char *data, size_t nread);
#else /* USE_NGHTTP2 */
#define Curl_http2_init(x) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_send_request(x) CURLE_UNSUPPORTED_PROTOCOL