NPOS macro
This commit is contained in:
@@ -157,7 +157,7 @@ void Webserv::_check_script_status(Client *client, std::string & output)
|
||||
int status_pos;
|
||||
|
||||
pos = output.find("Status:");
|
||||
if (pos != std::string::npos)
|
||||
if (pos != NPOS)
|
||||
{
|
||||
status_pos = pos + std::string("Status:").size();
|
||||
client->status = std::strtoul(output.c_str() + status_pos, NULL, 10);
|
||||
@@ -179,13 +179,13 @@ void Webserv::_check_script_fields(Client *client, std::string & output)
|
||||
// put server headers in map
|
||||
tmp = client->response;
|
||||
pos = tmp.find(CRLF CRLF);
|
||||
if (pos != std::string::npos)
|
||||
if (pos != NPOS)
|
||||
tmp.erase(pos);
|
||||
::parse_http_headers(tmp, srv_fld);
|
||||
// put script headers in map
|
||||
tmp = output;
|
||||
pos = tmp.find(CRLF CRLF);
|
||||
if (pos != std::string::npos)
|
||||
if (pos != NPOS)
|
||||
tmp.erase(pos);
|
||||
::parse_http_headers(tmp, scr_fld);
|
||||
// compare both map to supress duplicates
|
||||
|
||||
@@ -61,7 +61,8 @@ int Webserv::_read_request(Client *client)
|
||||
{
|
||||
if (client->get_rq_headers("Content-Type").empty()
|
||||
&& client->get_rq_headers("Content-Length").empty()
|
||||
&& client->get_rq_headers("Transfer-Encoding").empty())
|
||||
// && client->get_rq_headers("Transfer-Encoding").empty()
|
||||
)
|
||||
return READ_COMPLETE; // No body case
|
||||
}
|
||||
else if (client->raw_request.size() > MAX_HEADER_SIZE)
|
||||
|
||||
@@ -133,7 +133,7 @@ void Webserv::_append_body(Client *client, const std::string &body, const std::s
|
||||
else
|
||||
{
|
||||
client->response.append(mime_type);
|
||||
if (mime_type.find("text/") != std::string::npos)
|
||||
if (mime_type.find("text/") != NPOS)
|
||||
client->response.append("; charset=UTF-8");
|
||||
}
|
||||
client->response.append(CRLF);
|
||||
@@ -251,7 +251,7 @@ If we get a url that ends in / ignore the last /
|
||||
std::string Webserv::_determine_file_extension(const std::string &path) const
|
||||
{
|
||||
size_t dot_pos = path.rfind(".");
|
||||
if (dot_pos != std::string::npos && dot_pos + 1 < path.size())
|
||||
if (dot_pos != NPOS && dot_pos + 1 < path.size())
|
||||
return ( path.substr(dot_pos + 1) );
|
||||
return (std::string(""));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user