From 0aae7f2f585a48b21dbe818abcc14058afbdae97 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 19 Apr 2016 10:38:57 +0300 Subject: [PATCH] Adhere to the spec with connection keep-alive Recognize it case-insensitively and add the header on the response. --- source/http/server.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/http/server.cpp b/source/http/server.cpp index fbacb10..60d37c8 100644 --- a/source/http/server.cpp +++ b/source/http/server.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "request.h" #include "response.h" #include "server.h" @@ -132,7 +133,7 @@ void Server::client_data_available(Client &cl) { cl.keepalive = false; if(cl.request->has_header("Connection")) - cl.keepalive = (cl.request->get_header("Connection")=="keep-alive"); + cl.keepalive = !strcasecmp(cl.request->get_header("Connection"), "keep-alive"); response = new Response(NONE); try @@ -168,6 +169,8 @@ void Server::client_data_available(Client &cl) void Server::send_response(Client &cl, Response &resp) { + if(cl.keepalive) + resp.set_header("Connection", "keep-alive"); cl.sock->write(resp.str()); cl.async = false; if(cl.keepalive) -- 2.43.0