HTTP: implement trailing headers for chunked transfers#3350
HTTP: implement trailing headers for chunked transfers#3350aneutron wants to merge 1 commit intocurl:masterfrom
Conversation
7ddc698 to
39379db
Compare
bagder
left a comment
There was a problem hiding this comment.
Nice work! I've mostly found minor nits and details to remark on.
There was a problem hiding this comment.
@danielgustafsson it seems the travis check for copyright year mismatch doesn't work on new files?
There was a problem hiding this comment.
"custom pointer passed to the trailing headers callback" maybe? We want it to be short and sweet. It also makes sense to have all *DATA options described using similar wording.
docs/libcurl/curl_easy_setopt.3
Outdated
There was a problem hiding this comment.
A little bikeshedding here perhaps, but...
I'm not convinced it is a good idea to include HTTP in the name. What if there's another protocol with a similar concept that we could use this callback for at a later point in time? Maybe just CURLOPT_TRAILERFUNCTION ? Most of the existing *FUNCTION names are already named without a separating underscore.
There was a problem hiding this comment.
Since we discourage // comments everywhere (for C89 portability), we probably should use them in the man page example either...
There was a problem hiding this comment.
Here too I think this should be as short as possible that still conveys what it does:
"set callback for sending trailing headers" perhaps?
lib/transfer.c
Outdated
There was a problem hiding this comment.
When splitting long expressions, we usually prefer to split the lines with the operator on the previous line, and I would recommend parentheses:
(data->req.upload_chunky &&
(data->state.trailers_state == HTTP_TRAILERS_NONE))
lib/transfer.c
Outdated
lib/urldata.h
Outdated
lib/urldata.h
Outdated
There was a problem hiding this comment.
no point in explaining what it isn't...
lib/transfer.c
Outdated
There was a problem hiding this comment.
maybe add spaces to make this more readable?
return trailers_buf->size_used - data->state.trailers_bytes_sent;
e1424c3 to
b9bf487
Compare
|
I think I addressed all the remarks:
|
|
Please fix the typo in the commit message: "chuncked" --> "chunked". |
Yes I think so, since this is after all only for HTTP (now). |
This adds the CURLOPT_TRAILERDATA and CURLOPT_TRAILERFUNCTION options that allow a callback based approach to sending trailing headers with chunked transfers. 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.
b9bf487 to
502dc09
Compare
|
Thanks! |
|
Thanks a lot ! 😄 |
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.)