aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-08-13 12:12:14 +0200
committerDaniel Stenberg <daniel@haxx.se>2018-08-13 23:16:01 +0200
commit8440616f53056b2330393d1b0740c89a30376c67 (patch)
treeea2ea2300488f3c792ff7cf2a86e5047a3814e2f /tests/server
parent233908a55aa041d1ad3d901f9c3b8e3b1ebd3d55 (diff)
http: fix for tiny "HTTP/0.9" response
Deal with tiny "HTTP/0.9" (header-less) responses by checking the status-line early, even before a full "HTTP/" is received to allow detecting 0.9 properly. Test 1266 and 1267 added to verify. Fixes #2420 Closes #2872
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/sws.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 4879cfa8b..fbe7761d8 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -124,6 +124,8 @@ struct httprequest {
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 */
+ bool close; /* similar to swsclose in response: close connection after
+ response is sent */
int done_processing;
};
@@ -177,6 +179,9 @@ const char *serverlogfile = DEFAULT_LOGFILE;
/* upgrade to http2 */
#define CMD_UPGRADE "upgrade"
+/* close connection */
+#define CMD_SWSCLOSE "swsclose"
+
#define END_OF_HEADERS "\r\n\r\n"
enum {
@@ -361,7 +366,7 @@ static int parse_servercmd(struct httprequest *req)
int error;
filename = test2file(req->testno);
-
+ req->close = FALSE;
stream = fopen(filename, "rb");
if(!stream) {
error = errno;
@@ -414,6 +419,10 @@ static int parse_servercmd(struct httprequest *req)
logmsg("enabled upgrade to http2");
req->upgrade = TRUE;
}
+ else if(!strncmp(CMD_SWSCLOSE, cmd, strlen(CMD_SWSCLOSE))) {
+ logmsg("swsclose: close this connection after response");
+ req->close = TRUE;
+ }
else if(1 == sscanf(cmd, "pipe: %d", &num)) {
logmsg("instructed to allow a pipe size of %d", num);
if(num < 0)
@@ -1194,7 +1203,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
/* If the word 'swsclose' is present anywhere in the reply chunk, the
connection will be closed after the data has been sent to the requesting
client... */
- if(strstr(buffer, "swsclose") || !count) {
+ if(strstr(buffer, "swsclose") || !count || req->close) {
persistent = FALSE;
logmsg("connection close instruction \"swsclose\" found in response");
}