diff --git a/src/server.cpp b/src/server.cpp index f2872af..4c4c9e1 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -372,8 +372,15 @@ void Server::CheckHeaders(Client & client, size_t input_buffer_index) if( client.http_version == http_version_1_0 ) { - std::cout << "answer generated, closing connection for http 1.0" << std::endl; - client.close_connection = true; + if( !CompareNoCase(client.in.Text(L"connection"), L"keep-alive") ) + { + std::cout << "answer generated, closing connection for http 1.0" << std::endl; + client.close_connection = true; + } + else + { + std::cout << "keep-alive is set, not closing connection for http 1.0" << std::endl; + } } } @@ -477,6 +484,11 @@ void Server::CreateAnswer(Client & client) a += L"Content-Type: text/html; charset=UTF-8\r\n"; + if( CompareNoCase(client.in.Text(L"connection"), L"keep-alive") ) + { + a += L"Connection: keep-alive\r\n"; + } + wchar_t buf[32]; swprintf(buf, sizeof(buf)/sizeof(wchar_t), L"%d", c_ascii.size());