aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-01-08 03:04:19 -0500
committerJay Satiro <raysatiro@yahoo.com>2016-01-08 03:06:25 -0500
commit984d1e9e23a6cfa1ef6c233c681d82b0c018c493 (patch)
tree2ad845173cc981b4b504a6378089624828041a26
parentd9b4d1ce20e89a00dba8afc3767845fb7e357b21 (diff)
http2: Fix PUSH_PROMISE headers being treated as trailers
Discussed in https://github.com/bagder/curl/pull/564
-rw-r--r--lib/http2.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/http2.c b/lib/http2.c
index ba55877a5..31dd6f6cf 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -771,23 +771,6 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
- if(stream->bodystarted) {
- /* This is trailer fields. */
- /* 3 is for ":" and "\r\n". */
- uint32_t n = (uint32_t)(namelen + valuelen + 3);
-
- DEBUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen,
- value));
-
- Curl_add_buffer(stream->trailer_recvbuf, &n, sizeof(n));
- Curl_add_buffer(stream->trailer_recvbuf, name, namelen);
- Curl_add_buffer(stream->trailer_recvbuf, ":", 1);
- Curl_add_buffer(stream->trailer_recvbuf, value, valuelen);
- Curl_add_buffer(stream->trailer_recvbuf, "\r\n\0", 3);
-
- return 0;
- }
-
/* Store received PUSH_PROMISE headers to be used when the subsequent
PUSH_PROMISE callback comes */
if(frame->hd.type == NGHTTP2_PUSH_PROMISE) {
@@ -818,6 +801,23 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
return 0;
}
+ if(stream->bodystarted) {
+ /* This is trailer fields. */
+ /* 3 is for ":" and "\r\n". */
+ uint32_t n = (uint32_t)(namelen + valuelen + 3);
+
+ DEBUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen,
+ value));
+
+ Curl_add_buffer(stream->trailer_recvbuf, &n, sizeof(n));
+ Curl_add_buffer(stream->trailer_recvbuf, name, namelen);
+ Curl_add_buffer(stream->trailer_recvbuf, ":", 1);
+ Curl_add_buffer(stream->trailer_recvbuf, value, valuelen);
+ Curl_add_buffer(stream->trailer_recvbuf, "\r\n\0", 3);
+
+ return 0;
+ }
+
if(namelen == sizeof(":status") - 1 &&
memcmp(":status", name, namelen) == 0) {
/* nghttp2 guarantees :status is received first and only once, and