aboutsummaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-12-13 19:32:58 +0900
committerDaniel Stenberg <daniel@haxx.se>2015-12-15 23:47:46 +0100
commit15cb03ad846a10c4aa4889d46804389ad11cdc1d (patch)
tree7b2e270cc7980ed5d1a54e08f10a958e14f95645 /lib/http.c
parent871ad2a0f242ee036f35ccc6c48e5baa6389885f (diff)
http2: Support trailer fields
This commit adds trailer support in HTTP/2. In HTTP/1.1, chunked encoding must be used to send trialer fields. HTTP/2 deprecated any trandfer-encoding, including chunked. But trailer fields are now always available. Since trailer fields are relatively rare these days (gRPC uses them extensively though), allocating buffer for trailer fields is done when we detect that HEADERS frame containing trailer fields is started. We use Curl_add_buffer_* functions to buffer all trailers, just like we do for regular header fields. And then deliver them when stream is closed. We have to be careful here so that all data are delivered to upper layer before sending trailers to the application. We can deliver trailer field one by one using NGHTTP2_ERR_PAUSE mechanism, but current method is far more simple. Another possibility is use chunked encoding internally for HTTP/2 traffic. I have not tested it, but it could add another overhead. Closes #564
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/http.c b/lib/http.c
index b77003fe7..f2a644fb5 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1478,6 +1478,8 @@ CURLcode Curl_http_done(struct connectdata *conn,
DEBUGF(infof(data, "free header_recvbuf!!\n"));
Curl_add_buffer_free(http->header_recvbuf);
http->header_recvbuf = NULL; /* clear the pointer */
+ Curl_add_buffer_free(http->trailer_recvbuf);
+ http->trailer_recvbuf = NULL; /* clear the pointer */
if(http->push_headers) {
/* if they weren't used and then freed before */
for(; http->push_headers_used > 0; --http->push_headers_used) {