mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 13:27:59 +03:00
replacement: reference getters
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
#include "Location.hpp"
|
|
||||||
|
|
||||||
Location::Location()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Location::~Location()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef LOCATION_HPP
|
|
||||||
#define LOCATION_HPP
|
|
||||||
|
|
||||||
#include "webserv.hpp"
|
|
||||||
#include "ServerConfig.hpp"
|
|
||||||
|
|
||||||
class Location
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
location *loc;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Location();
|
|
||||||
~Location();
|
|
||||||
|
|
||||||
void setLocation(location *location);
|
|
||||||
bool checkLocation(std::string URI);
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -32,39 +32,39 @@ Request::Request(char *str)
|
|||||||
|
|
||||||
//-------------------------------------------------Get/Set---------------------------------------
|
//-------------------------------------------------Get/Set---------------------------------------
|
||||||
|
|
||||||
std::string Request::getURI(void)
|
std::string &Request::getURI(void)
|
||||||
{
|
{
|
||||||
return (_URI);
|
return (_URI);
|
||||||
}
|
}
|
||||||
std::string Request::getBody(void)
|
std::string &Request::getBody(void)
|
||||||
{
|
{
|
||||||
return (_body);
|
return (_body);
|
||||||
}
|
}
|
||||||
std::string Request::getHost(void)
|
std::string &Request::getHost(void)
|
||||||
{
|
{
|
||||||
return (_host);
|
return (_host);
|
||||||
}
|
}
|
||||||
std::string Request::getQuery(void)
|
std::string &Request::getQuery(void)
|
||||||
{
|
{
|
||||||
return(_query);
|
return(_query);
|
||||||
}
|
}
|
||||||
std::string Request::getMethod(void)
|
std::string &Request::getMethod(void)
|
||||||
{
|
{
|
||||||
return (_method);
|
return (_method);
|
||||||
}
|
}
|
||||||
std::string Request::getFullUri(void)
|
std::string &Request::getFullUri(void)
|
||||||
{
|
{
|
||||||
return (_fullURI);
|
return (_fullURI);
|
||||||
}
|
}
|
||||||
std::string Request::getVersion(void)
|
std::string &Request::getVersion(void)
|
||||||
{
|
{
|
||||||
return (_version);
|
return (_version);
|
||||||
}
|
}
|
||||||
std::string Request::getLocation(void)
|
std::string &Request::getLocation(void)
|
||||||
{
|
{
|
||||||
return (_location);
|
return (_location);
|
||||||
}
|
}
|
||||||
std::string Request::getConnection(void)
|
std::string &Request::getConnection(void)
|
||||||
{
|
{
|
||||||
return (_connection);
|
return (_connection);
|
||||||
}
|
}
|
||||||
@@ -155,8 +155,6 @@ int Request::parseStartLine(std::string str)
|
|||||||
else if (_method != "GET" && _method != "POST"
|
else if (_method != "GET" && _method != "POST"
|
||||||
&& _method != "DELETE")
|
&& _method != "DELETE")
|
||||||
_ret = 405;
|
_ret = 405;
|
||||||
else if (isFile(_fullURI) != 0 && isDir(_fullURI) != 0)
|
|
||||||
_ret = 404;
|
|
||||||
return (_ret);
|
return (_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +201,7 @@ int Request::parseClientfield(std::string str)
|
|||||||
|
|
||||||
distance = str.find(":");
|
distance = str.find(":");
|
||||||
if (distance < 0 && str != "\r")
|
if (distance < 0 && str != "\r")
|
||||||
return 400;
|
return 200;
|
||||||
key = str.substr(0, distance);
|
key = str.substr(0, distance);
|
||||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||||
value = str.erase(0, distance + 1);
|
value = str.erase(0, distance + 1);
|
||||||
|
|||||||
@@ -34,15 +34,15 @@ private:
|
|||||||
bool _body_ok;
|
bool _body_ok;
|
||||||
bool _chunked;
|
bool _chunked;
|
||||||
public:
|
public:
|
||||||
std::string getURI(void);
|
std::string &getURI(void);
|
||||||
std::string getBody(void);
|
std::string &getBody(void);
|
||||||
std::string getHost(void);
|
std::string &getHost(void);
|
||||||
std::string getQuery(void);
|
std::string &getQuery(void);
|
||||||
std::string getMethod(void);
|
std::string &getMethod(void);
|
||||||
std::string getFullUri(void);
|
std::string &getFullUri(void);
|
||||||
std::string getVersion(void);
|
std::string &getVersion(void);
|
||||||
std::string getLocation(void);
|
std::string &getLocation(void);
|
||||||
std::string getConnection(void);
|
std::string &getConnection(void);
|
||||||
ServerConfig *getConfig(void);
|
ServerConfig *getConfig(void);
|
||||||
int getCode(void);
|
int getCode(void);
|
||||||
int getLifeTime(void);
|
int getLifeTime(void);
|
||||||
|
|||||||
@@ -13,32 +13,32 @@ ServerConfig::ServerConfig(TOMLMap *map)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------GET/SET---------------------------------------
|
//--------------------------------------------------GET/SET---------------------------------------
|
||||||
std::string ServerConfig::getServerName(void)
|
std::string &ServerConfig::getServerName(void)
|
||||||
{
|
{
|
||||||
return (_serverName);
|
return (_serverName);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ServerConfig::getHost(void)
|
std::string &ServerConfig::getHost(void)
|
||||||
{
|
{
|
||||||
return (_host);
|
return (_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerConfig::getPort(void)
|
int &ServerConfig::getPort(void)
|
||||||
{
|
{
|
||||||
return (_port);
|
return (_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerConfig::getClientBodySize(void)
|
int &ServerConfig::getClientBodySize(void)
|
||||||
{
|
{
|
||||||
return (_clientBodySize);
|
return (_clientBodySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<location *> ServerConfig::getLocations(void)
|
std::vector<location *> &ServerConfig::getLocations(void)
|
||||||
{
|
{
|
||||||
return (_locations);
|
return (_locations);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, std::string> ServerConfig::getErrorPages(void)
|
std::map<int, std::string> &ServerConfig::getErrorPages(void)
|
||||||
{
|
{
|
||||||
return (_errorPages);
|
return (_errorPages);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ struct location
|
|||||||
std::map<int, std::string> redirect;
|
std::map<int, std::string> redirect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct serverListen
|
||||||
|
{
|
||||||
|
std::string ip;
|
||||||
|
int port;
|
||||||
|
};
|
||||||
|
|
||||||
class ServerConfig
|
class ServerConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -39,12 +45,12 @@ public:
|
|||||||
void setLocations(std::vector<location *>);
|
void setLocations(std::vector<location *>);
|
||||||
void setRoot(TOMLMap *);
|
void setRoot(TOMLMap *);
|
||||||
|
|
||||||
std::string getServerName(void);
|
std::string &getServerName(void);
|
||||||
std::string getHost(void);
|
std::string &getHost(void);
|
||||||
int getPort(void);
|
int &getPort(void);
|
||||||
int getClientBodySize(void);
|
int &getClientBodySize(void);
|
||||||
std::vector<location *> getLocations(void);
|
std::vector<location *> &getLocations(void);
|
||||||
std::map<int, std::string> getErrorPages(void);
|
std::map<int, std::string> &getErrorPages(void);
|
||||||
TOMLMap *getRoot(void);
|
TOMLMap *getRoot(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user