aboutsummaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-01-07 22:10:09 +0900
committerJay Satiro <raysatiro@yahoo.com>2016-01-08 17:16:47 -0500
commitb019af41e7d09cb75c461e33de5ce7a8c461dc43 (patch)
treed54fa39aecabcc7385289af8e94c1535691c4f57 /lib/transfer.c
parent325686ef9eaf969830965ecaf044289cf8777f49 (diff)
http2: Ensure that http2_handle_stream_close is called
Previously, when HTTP/2 is enabled and used, and stream has content length known, Curl_read was not called when there was no bytes left to read. Because of this, we could not make sure that http2_handle_stream_close was called for every stream. Since we use http2_handle_stream_close to emit trailer fields, they were effectively ignored. This commit changes the code so that Curl_read is called even if no bytes left to read, to ensure that http2_handle_stream_close is called for every stream. Discussed in https://github.com/bagder/curl/pull/564
Diffstat (limited to 'lib/transfer.c')
-rw-r--r--lib/transfer.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index 91777d6f5..d6e1f4dc1 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -410,7 +410,18 @@ static CURLcode readwrite_data(struct SessionHandle *data,
data->set.buffer_size : BUFSIZE;
size_t bytestoread = buffersize;
- if(k->size != -1 && !k->header) {
+ if(
+#if defined(USE_NGHTTP2)
+ /* For HTTP/2, read data without caring about the content
+ length. This is safe because body in HTTP/2 is always
+ segmented thanks to its framing layer. Meanwhile, we have to
+ call Curl_read to ensure that http2_handle_stream_close is
+ called when we read all incoming bytes for a particular
+ stream. */
+ !((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
+ conn->httpversion == 20) &&
+#endif
+ k->size != -1 && !k->header) {
/* make sure we don't read "too much" if we can help it since we
might be pipelining and then someone else might want to read what
follows! */