From f9a01915b40e2e40126b362d874a9a271dfc5af2 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 19 Aug 2014 12:51:23 +0200 Subject: [PATCH] nhttp: some minor code optimizations Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/2c3952cf42d6c385078b7c4b22b3ca57743cd0d4 Author: vanhofen Date: 2014-08-19 (Tue, 19 Aug 2014) Origin message was: ------------------ - nhttp: some minor code optimizations --- src/nhttpd/yhttpd_core/yconnection.cpp | 5 ++--- src/nhttpd/yhttpd_core/yhook.cpp | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/nhttpd/yhttpd_core/yconnection.cpp b/src/nhttpd/yhttpd_core/yconnection.cpp index ea16280b5..ea36c0c7c 100644 --- a/src/nhttpd/yhttpd_core/yconnection.cpp +++ b/src/nhttpd/yhttpd_core/yconnection.cpp @@ -96,10 +96,9 @@ void CWebserverConnection::HandleConnection() { if(string_tolower(Request.HeaderList["Connection"]) == "close" || (httprotocol != "HTTP/1.1" && string_tolower(Request.HeaderList["Connection"]) != "keep-alive") || !Webserver->CheckKeepAliveAllowedByIP(sock->get_client_ip())) - keep_alive = false; -#else - keep_alive = false; #endif + keep_alive = false; + // Send a response Response.SendResponse(); diff --git a/src/nhttpd/yhttpd_core/yhook.cpp b/src/nhttpd/yhttpd_core/yhook.cpp index 9246edec8..3b789864f 100644 --- a/src/nhttpd/yhttpd_core/yhook.cpp +++ b/src/nhttpd/yhttpd_core/yhook.cpp @@ -248,9 +248,8 @@ std::string CyhookHandler::BuildHeader(bool cache) { break; } // print Status-line - result = string_printf(HTTP_PROTOCOL " %d %s\r\nContent-Type: %s\r\n",httpStatus, responseString, ResponseMimeType.c_str()); - log_level_printf(2, "Response: HTTP/1.1 %d %s\r\nContent-Type: %s\r\n", - httpStatus, responseString, ResponseMimeType.c_str()); + result = string_printf(HTTP_PROTOCOL " %d %s\r\nContent-Type: %s\r\n", httpStatus, responseString, ResponseMimeType.c_str()); + log_level_printf(2, "Response: HTTP/1.1 %d %s\r\nContent-Type: %s\r\n", httpStatus, responseString, ResponseMimeType.c_str()); switch (httpStatus) { case HTTP_UNAUTHORIZED: @@ -285,7 +284,7 @@ std::string CyhookHandler::BuildHeader(bool cache) { // connection type #ifdef Y_CONFIG_FEATURE_KEEP_ALIVE if(keep_alive) - result += "Connection: keep-alive\r\n"; + result += "Connection: keep-alive\r\n"; else #endif result += "Connection: close\r\n";