aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-02-26 22:48:09 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-02-26 22:48:14 +0100
commit6375b205a9d3ebe9583871178db258e6a1f4dfff (patch)
tree425ef8d1e1d3c6c23c83f9eefb491ec14935e087 /tests/server
parent8220ec82196f8331460f68b676b7aea6d9e3e806 (diff)
http: added 417 response treatment
When doing a request with a body + Expect: 100-continue and the server responds with a 417, the same request will be retried immediately without the Expect: header. Added test 357 to verify. Also added a control instruction to tell the sws test server to not read the request body if Expect: is present, which the new test 357 uses. Reported-by: bramus on github Fixes #4949 Closes #4964
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/sws.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 65f8aa619..eed2d5fd9 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -118,6 +118,8 @@ struct httprequest {
int rcmd; /* doing a special command, see defines above */
int prot_version; /* HTTP version * 10 */
int callcount; /* times ProcessRequest() gets called */
+ bool skipall; /* skip all incoming data */
+ bool noexpect; /* refuse Expect: (don't read the body) */
bool connmon; /* monitor the state of the connection, log disconnects */
bool upgrade; /* test case allows upgrade to http2 */
bool upgrade_request; /* upgrade request found and allowed */
@@ -179,6 +181,9 @@ const char *serverlogfile = DEFAULT_LOGFILE;
/* close connection */
#define CMD_SWSCLOSE "swsclose"
+/* deny Expect: requests */
+#define CMD_NOEXPECT "no-expect"
+
#define END_OF_HEADERS "\r\n\r\n"
enum {
@@ -427,6 +432,10 @@ static int parse_servercmd(struct httprequest *req)
logmsg("instructed to skip this number of bytes %d", num);
req->skip = num;
}
+ else if(!strncmp(CMD_NOEXPECT, cmd, strlen(CMD_NOEXPECT))) {
+ logmsg("instructed to reject Expect: 100-continue");
+ req->noexpect = TRUE;
+ }
else if(1 == sscanf(cmd, "writedelay: %d", &num)) {
logmsg("instructed to delay %d secs between packets", num);
req->writedelay = num;
@@ -735,19 +744,28 @@ static int ProcessRequest(struct httprequest *req)
req->open = FALSE; /* closes connection */
return 1; /* done */
}
- req->cl = clen - req->skip;
+ if(req->skipall)
+ req->cl = 0;
+ else
+ req->cl = clen - req->skip;
logmsg("Found Content-Length: %lu in the request", clen);
if(req->skip)
logmsg("... but will abort after %zu bytes", req->cl);
- break;
}
else if(strncasecompare("Transfer-Encoding: chunked", line,
strlen("Transfer-Encoding: chunked"))) {
/* chunked data coming in */
chunked = TRUE;
}
-
+ else if(req->noexpect &&
+ strncasecompare("Expect: 100-continue", line,
+ strlen("Expect: 100-continue"))) {
+ if(req->cl)
+ req->cl = 0;
+ req->skipall = TRUE;
+ logmsg("Found Expect: 100-continue, ignore body");
+ }
if(chunked) {
if(strstr(req->reqbuf, "\r\n0\r\n\r\n")) {
@@ -939,6 +957,8 @@ static void init_httprequest(struct httprequest *req)
req->digest = FALSE;
req->ntlm = FALSE;
req->skip = 0;
+ req->skipall = FALSE;
+ req->noexpect = FALSE;
req->writedelay = 0;
req->rcmd = RCMD_NORMALREQ;
req->prot_version = 0;