fixed response.append(body) problem.

+ File I/O working but maybe not perfect (it seems complicated to do it with std::filebuf)
+ fixed Content-Type for unknown file extension
This commit is contained in:
LuckyLaszlo
2022-08-07 01:38:33 +02:00
parent b0df37df60
commit 8ec1353723
5 changed files with 54 additions and 62 deletions

View File

@@ -38,6 +38,8 @@ void signal_handler(int signum);
# define FAILURE -1
# define SUCCESS 1
# define MIME_TYPE_DEFAULT "application/octet-stream"
class Webserv
{
public:
@@ -78,7 +80,7 @@ class Webserv
void _process_method(Client *client, ServerConfig &server, LocationConfig &location);
void _insert_status_line(Client *client);
void _error_html_response(Client *client, ServerConfig &server);
void _append_body(Client *client, const char *body, size_t body_size, const std::string &file_extension = "");
void _append_body(Client *client, const std::string &body, const std::string &file_extension = "");
void _get(Client *client, ServerConfig &server, LocationConfig &location);
void _get_file(Client *client, const std::string &path);
@@ -90,7 +92,8 @@ class Webserv
void _delete_file(Client *client, const std::string &path);
ServerConfig &_determine_process_server(Client *client);
LocationConfig &_determine_location(ServerConfig &server, std::string &path);
LocationConfig &_determine_location(ServerConfig &server, const std::string &path);
std::string _determine_file_extension(const std::string &path) const;
// cgi_script.cpp
bool _is_cgi(Client *client);
void _exec_cgi(Client *client);