Multiples minors changes (cgi env, comment, ...)
This commit is contained in:
@@ -1,24 +1,13 @@
|
||||
|
||||
#include "Webserv.hpp"
|
||||
|
||||
std::string Webserv::_replace_url_root(Client *client, std::string path)
|
||||
{
|
||||
std::cerr << "assigned_location->path = " << client->assigned_location->path << "\n"; // debug
|
||||
std::cerr << "path before = " << path << "\n"; // DEBUG
|
||||
if (client->assigned_location->path == "/")
|
||||
path.insert(0, client->assigned_location->root);
|
||||
else
|
||||
path.replace(0, client->assigned_location->path.size(), client->assigned_location->root);
|
||||
std::cerr << "path after = " << path << "\n"; // DEBUG
|
||||
return path;
|
||||
}
|
||||
#define MAX_FILESIZE 1 * MB // unused
|
||||
|
||||
// const?
|
||||
void Webserv::_get(Client *client, std::string &path)
|
||||
{
|
||||
/*
|
||||
https://www.rfc-editor.org/rfc/rfc9110.html#name-get
|
||||
*/
|
||||
void Webserv::_get(Client *client, std::string &path)
|
||||
{
|
||||
std::cout << "_get()\n";
|
||||
if (eval_file_type(path) == IS_DIR)
|
||||
{
|
||||
@@ -42,14 +31,13 @@ void Webserv::_get(Client *client, std::string &path)
|
||||
_get_file(client, path);
|
||||
}
|
||||
|
||||
# define MAX_FILESIZE 1 * MB // unused
|
||||
void Webserv::_get_file(Client *client, const std::string &path)
|
||||
{
|
||||
/*
|
||||
std::ios::binary
|
||||
https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary
|
||||
tldr : its seems to not be so simple to do read/write of binary file in a portable way.
|
||||
*/
|
||||
void Webserv::_get_file(Client *client, const std::string &path)
|
||||
{
|
||||
std::ifstream ifd; // For chunk, ifstream directly in struct CLient for multiples read without close() ?
|
||||
std::stringstream buf;
|
||||
|
||||
@@ -155,3 +143,11 @@ void Webserv::_autoindex(Client *client, const std::string &path)
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Webserv::_determine_file_extension(const std::string &path) const
|
||||
{
|
||||
size_t dot_pos = path.rfind(".");
|
||||
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