Browse Source

Fix keep-alive

bel 11 years ago
parent
commit
2c5d90b829
1 changed files with 5 additions and 4 deletions
  1. 5 4
      src/civetweb.c

+ 5 - 4
src/civetweb.c

@@ -202,7 +202,7 @@ typedef struct DIR {
     struct dirent  result;
 } DIR;
 
-#ifndef USE_IPV6 && defined(_WIN32)
+#if !defined(USE_IPV6) && defined(_WIN32)
 #ifndef HAVE_POLL
 struct pollfd {
     SOCKET fd;
@@ -3514,7 +3514,7 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog)
     char *buf;
     size_t buflen;
     int headers_len, data_len, i, fdin[2] = { 0, 0 }, fdout[2] = { 0, 0 };
-    const char *status, *status_text;
+    const char *status, *status_text, *connection_state;
     char *pbuf, dir[PATH_MAX], *p;
     struct mg_request_info ri;
     struct cgi_env_block blk;
@@ -3624,8 +3624,9 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog)
     } else {
         conn->status_code = 200;
     }
-    if (get_header(&ri, "Connection") != NULL &&
-        !mg_strcasecmp(get_header(&ri, "Connection"), "keep-alive")) {
+    connection_state = get_header(&ri, "Connection");
+    if (connection_state == NULL ||
+        mg_strcasecmp(connection_state, "keep-alive")) {
         conn->must_close = 1;
     }
     (void) mg_printf(conn, "HTTP/1.1 %d %s\r\n", conn->status_code,