bad_alloc handling

+ map.insert() replace map.operator[] for init, more efficient
This commit is contained in:
LuckyLaszlo
2022-08-08 04:24:03 +02:00
parent 1ccf61bc68
commit 02cfdf43bc
8 changed files with 162 additions and 136 deletions

View File

@@ -15,7 +15,8 @@ void Webserv::_send_response(Client *client)
std::cerr << "send()\n";
_append_base_headers(client);
_construct_response(client);
if (!client->status)
_construct_response(client);
_insert_status_line(client);
if (client->status >= 400)
_error_html_response(client);
@@ -181,7 +182,6 @@ void Webserv::_get_file(Client *client, const std::string &path)
// Then chunk
client->status = 500; // WIP temp
std::cerr << "File too large for non chunk body\n";
ifd.close();
return ;
}
@@ -198,8 +198,6 @@ void Webserv::_get_file(Client *client, const std::string &path)
std::string file_ext = _determine_file_extension(path);
_append_body(client, buf.str(), file_ext);
}
ifd.close();
}
}
@@ -287,8 +285,6 @@ void Webserv::_post_file(Client *client, const std::string &path)
client->status = 201;
// WIP https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.3-4
}
ofd.close();
}
}