aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
authorAyoub Boudhar <a.boudhar@outlook.com>2018-12-06 10:18:03 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-12-14 10:10:48 +0100
commitf464535bfdd9a83140d8a13c3fe3d937239d1c2a (patch)
treeda330b66fe21c30ef5821436fa53a56e5946b504 /tests/server
parent4531b299cc4771e6d2428fb22c1305f75db71666 (diff)
http: Implement trailing headers for chunked transfers
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. Closes #3350
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/sws.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index cf3d291d9..87c0204c9 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -253,6 +253,9 @@ SIG_ATOMIC_T got_exit_signal = 0;
static volatile int exit_signal = 0;
+/* work around for handling trailing headers */
+static int already_recv_zeroed_chunk = FALSE;
+
/* signal handler that will be triggered to indicate that the program
should finish its execution in a controlled manner as soon as possible.
The first time this is called it will set got_exit_signal to one and
@@ -755,10 +758,27 @@ static int ProcessRequest(struct httprequest *req)
chunked = TRUE;
}
+
if(chunked) {
- if(strstr(req->reqbuf, "\r\n0\r\n\r\n"))
+ if(strstr(req->reqbuf, "\r\n0\r\n\r\n")) {
/* end of chunks reached */
return 1; /* done */
+ }
+ else if(strstr(req->reqbuf, "\r\n0\r\n")) {
+ char *last_crlf_char = strstr(req->reqbuf, "\r\n\r\n");
+ while(TRUE) {
+ if(!strstr(last_crlf_char + 4, "\r\n\r\n"))
+ break;
+ last_crlf_char = strstr(last_crlf_char + 4, "\r\n\r\n");
+ }
+ if(last_crlf_char &&
+ last_crlf_char > strstr(req->reqbuf, "\r\n0\r\n"))
+ return 1;
+ already_recv_zeroed_chunk = TRUE;
+ return 0;
+ }
+ else if(already_recv_zeroed_chunk && strstr(req->reqbuf, "\r\n\r\n"))
+ return 1;
else
return 0; /* not done */
}