fixed _error_html_response()
+ renamed eval_file_mode() in eval_file_access() + memo update
This commit is contained in:
@@ -47,7 +47,7 @@ int Webserv::_send_response(Client *client)
|
||||
if (client->status >= 400)
|
||||
_error_html_response(client);
|
||||
|
||||
/*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output + headers]:" RESET "\n"; ::print_special(client->response); std::cout << "\n" B_PURPLE "-----------" RESET "\n\n";
|
||||
// /*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output + headers]:" RESET "\n"; ::print_special(client->response); std::cout << "\n" B_PURPLE "-----------" RESET "\n\n";
|
||||
|
||||
std::cerr << "client->response.size() = " << client->response.size() << "\n"; // DEBUG
|
||||
ret = ::send(client->get_cl_fd(), client->response.c_str(), client->response.size(), 0);
|
||||
@@ -131,14 +131,20 @@ void Webserv::_insert_status_line(Client *client)
|
||||
|
||||
void Webserv::_error_html_response(Client *client)
|
||||
{
|
||||
if (!client->assigned_server || client->assigned_server->error_pages[client->status].empty())
|
||||
std::cout << "_error_html_response()\n";
|
||||
|
||||
if (client->assigned_server
|
||||
&& !client->assigned_server->error_pages[client->status].empty()
|
||||
&& ::eval_file_access(client->assigned_server->error_pages[client->status], R_OK) == 0 )
|
||||
{
|
||||
_get_file(client, client->assigned_server->error_pages[client->status]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string html_page = HTML_ERROR;
|
||||
::replace_all_substr(html_page, STATUS_PLACEHOLDER, _http_status[client->status]);
|
||||
_append_body(client, html_page, "html");
|
||||
}
|
||||
else
|
||||
_get_file(client, client->assigned_server->error_pages[client->status]);
|
||||
}
|
||||
|
||||
void Webserv::_append_body(Client *client, const std::string &body, const std::string &file_extension)
|
||||
|
||||
Reference in New Issue
Block a user