diff --git a/include/frnetlib/Http.h b/include/frnetlib/Http.h index eb06a2e..07cd1ce 100644 --- a/include/frnetlib/Http.h +++ b/include/frnetlib/Http.h @@ -155,7 +155,7 @@ namespace fr * @param key The name of the header * @return A reference to the header */ - std::string &header(const std::string &key); + std::string &header(std::string &&key); /*! diff --git a/src/Http.cpp b/src/Http.cpp index 01322b6..b26f71f 100644 --- a/src/Http.cpp +++ b/src/Http.cpp @@ -151,8 +151,9 @@ namespace fr return result; } - std::string &Http::header(const std::string &key) + std::string &Http::header(std::string &&key) { + std::transform(key.begin(), key.end(), key.begin(), ::tolower); return header_data[key]; } diff --git a/src/HttpResponse.cpp b/src/HttpResponse.cpp index 642fa1e..539f027 100644 --- a/src/HttpResponse.cpp +++ b/src/HttpResponse.cpp @@ -45,15 +45,15 @@ namespace fr //Add the headers to the response for(const auto &header : header_data) { - std::string data = header.first + ": " + url_encode(header.second) + "\r\n"; + std::string data = header.first + ": " + header.second + "\r\n"; response += data; } //Add in required headers if they're missing - if(header_data.find("Connection") == header_data.end()) - response += "Connection: close_socket\r\n"; - if(header_data.find("Content-type") == header_data.end()) - response += "Content-type: text/html\r\n"; + if(header_data.find("connection") == header_data.end()) + response += "connection: close_socket\r\n"; + if(header_data.find("content-type") == header_data.end()) + response += "content-type: text/html\r\n"; //Add in space response += "\r\n";