From: Mikko Rasa Date: Tue, 19 Apr 2016 07:38:57 +0000 (+0300) Subject: Adhere to the spec with connection keep-alive X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0aae7f2f585a48b21dbe818abcc14058afbdae97;p=libs%2Fnet.git Adhere to the spec with connection keep-alive Recognize it case-insensitively and add the header on the response. --- 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)