aboutsummaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-02-27 01:21:17 +0900
committerDaniel Stenberg <daniel@haxx.se>2014-02-28 23:28:39 +0100
commitcde0cf7c5ede69c68cb00cba3d1a6ccc27c24bc9 (patch)
tree1072828797a999c8d68a4e70ec65a9ec9d629bcf /lib/transfer.c
parent53f1f4a18ee7e3ac5fbe44a0e16b33b27465432b (diff)
Fix bug that HTTP/2 hangs if whole response body is read with headers
For HTTP/2, we may read up everything including responde body with header fields in Curl_http_readwrite_headers. If no content-length is provided, curl waits for the connection close, which we emulate it using conn->proto.httpc.closed = TRUE. The thing is if we read everything, then http2_recv won't be called and we cannot signal the HTTP/2 stream has closed. As a workaround, we return nonzero from data_pending to call http2_recv.
Diffstat (limited to 'lib/transfer.c')
-rw-r--r--lib/transfer.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index 83727db68..8748c6a01 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -310,7 +310,16 @@ static int data_pending(const struct connectdata *conn)
/* in the case of libssh2, we can never be really sure that we have emptied
its internal buffers so we MUST always try until we get EAGAIN back */
return conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP) ||
- Curl_ssl_data_pending(conn, FIRSTSOCKET);
+ Curl_ssl_data_pending(conn, FIRSTSOCKET) ||
+ /* For HTTP/2, we may read up everything including responde body
+ with header fields in Curl_http_readwrite_headers. If no
+ content-length is provided, curl waits for the connection
+ close, which we emulate it using conn->proto.httpc.closed =
+ TRUE. The thing is if we read everything, then http2_recv won't
+ be called and we cannot signal the HTTP/2 stream has closed. As
+ a workaround, we return nonzero here to call http2_recv. */
+ ((conn->handler->protocol&CURLPROTO_HTTP) && conn->httpversion == 20 &&
+ conn->proto.httpc.closed);
}
static void read_rewind(struct connectdata *conn,