Header names are automatically lower-cased now.
This commit is contained in:
parent
561b395e93
commit
53ab6e2090
@ -155,7 +155,7 @@ namespace fr
|
|||||||
* @param key The name of the header
|
* @param key The name of the header
|
||||||
* @return A reference to the header
|
* @return A reference to the header
|
||||||
*/
|
*/
|
||||||
std::string &header(const std::string &key);
|
std::string &header(std::string &&key);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@ -151,8 +151,9 @@ namespace fr
|
|||||||
return result;
|
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];
|
return header_data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,15 +45,15 @@ namespace fr
|
|||||||
//Add the headers to the response
|
//Add the headers to the response
|
||||||
for(const auto &header : header_data)
|
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;
|
response += data;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add in required headers if they're missing
|
//Add in required headers if they're missing
|
||||||
if(header_data.find("Connection") == header_data.end())
|
if(header_data.find("connection") == header_data.end())
|
||||||
response += "Connection: close_socket\r\n";
|
response += "connection: close_socket\r\n";
|
||||||
if(header_data.find("Content-type") == header_data.end())
|
if(header_data.find("content-type") == header_data.end())
|
||||||
response += "Content-type: text/html\r\n";
|
response += "content-type: text/html\r\n";
|
||||||
|
|
||||||
//Add in space
|
//Add in space
|
||||||
response += "\r\n";
|
response += "\r\n";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user