mirror of
https://github.com/curl/curl.git
synced 2024-11-27 05:50:21 +08:00
http2: Fix PUSH_PROMISE headers being treated as trailers
Discussed in https://github.com/bagder/curl/pull/564
This commit is contained in:
parent
d9b4d1ce20
commit
984d1e9e23
34
lib/http2.c
34
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
|
||||
|
Loading…
Reference in New Issue
Block a user