aboutsummaryrefslogtreecommitdiff
path: root/lib/http2.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-09-05 11:07:40 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-09-05 14:32:32 +0200
commit3d4c0c8b9bc1d53df2e38961343f755a84579f83 (patch)
tree5d65b00a686516d8e6d70434810d7a4ab6f28a09 /lib/http2.c
parent03bb48159831682fb39a92a6b62b7c4551ef63c8 (diff)
http2: return EOF when done uploading without known size
Fixes #982
Diffstat (limited to 'lib/http2.c')
-rw-r--r--lib/http2.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/lib/http2.c b/lib/http2.c
index 17915d45a..a66b8f74c 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -1149,7 +1149,8 @@ static int h2_session_send(struct Curl_easy *data,
*/
static int h2_process_pending_input(struct Curl_easy *data,
struct http_conn *httpc,
- CURLcode *err) {
+ CURLcode *err)
+{
ssize_t nread;
char *inbuf;
ssize_t rv;
@@ -1197,9 +1198,41 @@ static int h2_process_pending_input(struct Curl_easy *data,
return 0;
}
+/*
+ * Called from transfer.c:done_sending when we stop uploading.
+ */
+CURLcode Curl_http2_done_sending(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+
+ if((conn->handler == &Curl_handler_http2_ssl) ||
+ (conn->handler == &Curl_handler_http2)) {
+ /* make sure this is only attempted for HTTP/2 transfers */
+
+ struct HTTP *stream = conn->data->req.protop;
+
+ if(stream->upload_left) {
+ /* If the stream still thinks there's data left to upload. */
+ struct http_conn *httpc = &conn->proto.httpc;
+ nghttp2_session *h2 = httpc->h2;
+
+ stream->upload_left = 0; /* DONE! */
+
+ /* resume sending here to trigger the callback to get called again so
+ that it can signal EOF to nghttp2 */
+ (void)nghttp2_session_resume_data(h2, stream->stream_id);
+
+ (void)h2_process_pending_input(conn->data, httpc, &result);
+ }
+ }
+ return result;
+}
+
+
static ssize_t http2_handle_stream_close(struct connectdata *conn,
struct Curl_easy *data,
- struct HTTP *stream, CURLcode *err) {
+ struct HTTP *stream, CURLcode *err)
+{
char *trailer_pos, *trailer_end;
CURLcode result;
struct http_conn *httpc = &conn->proto.httpc;