Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
HTTP: implement trailing headers for chunked transfers #3350
This patch adds the CURLOPT_TRAILERDATA and CURLOPT_TRAILERFUNCTION options that allow a callback based approach to sending trailing headers with chunked transfers.
Following the everything is a state machine mantra, it's four stages state machine that traps right before sending the final CRLF, calls the trailer function that fills a curl_slist with the trailers, compiles them into a single buffer, and proceeds to read from the buffer as if reading from the read callback, then jumps back into the next main state as if nothing happened.
The test server (sws) was updated to take into account the detection of the end of transfer in the case of trailing headers presence.
Test 1591 checks that trailing headers can be sent using libcurl.
(I'm very sorry I had to remake this PR, the first one was made to merge my master branch into the curl master branch, it was a rookie mistake that made rebasing difficult ... That and the lack of tests, half-baked docs and tests that didn't pass. Suffice to say that mistakes were made. I sincerely apologize. All the remarks on the previous PR were addressed.)
I think I addressed all the remarks: