fixed CGI alloc
+ handle unknow status from script
This commit is contained in:
@@ -122,9 +122,12 @@ void Webserv::_process_method(Client *client, std::string &path)
|
||||
void Webserv::_insert_status_line(Client *client)
|
||||
{
|
||||
std::string status_line;
|
||||
std::string status = _http_status[client->status];
|
||||
if (status.empty())
|
||||
status = ::itos(client->status);
|
||||
|
||||
status_line.append("HTTP/1.1 ");
|
||||
status_line.append(_http_status[client->status]);
|
||||
status_line.append(status);
|
||||
status_line.append(CRLF);
|
||||
client->response.insert(0, status_line);
|
||||
}
|
||||
@@ -141,8 +144,11 @@ void Webserv::_error_html_response(Client *client)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string status = _http_status[client->status];
|
||||
if (status.empty())
|
||||
status = "Error " + ::itos(client->status);
|
||||
std::string html_page = HTML_ERROR;
|
||||
::replace_all_substr(html_page, STATUS_PLACEHOLDER, _http_status[client->status]);
|
||||
::replace_all_substr(html_page, STATUS_PLACEHOLDER, status);
|
||||
_append_body(client, html_page, "html");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user