浏览代码

Add Keep-Alive header to response

Maksim Kolinichenko 7 年之前
父节点
当前提交
15ed1b4883
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      httplib.h

+ 5 - 1
httplib.h

@@ -1560,10 +1560,14 @@ inline void Server::write_response(Stream& strm, bool last_connection, const Req
 
     // Headers
     if (last_connection ||
-        req.version == "HTTP/1.0" ||
         req.get_header_value("Connection") == "close") {
         res.set_header("Connection", "close");
     }
+    
+    if (!last_connection &&
+        req.get_header_value("Connection") == "Keep-Alive") {
+        res.set_header("Connection", "Keep-Alive");
+    }
 
     if (!res.body.empty()) {
 #ifdef CPPHTTPLIB_ZLIB_SUPPORT