LeftHookRoll
An HTTP/1.0 compliant web server, as specified by RFC1945
Loading...
Searching...
No Matches
ServerConf.cpp
Go to the documentation of this file.
1
2#include "../includes/ServerConf.hpp"
3
4
5ServerConf::ServerConf() : _maxBodySize(0)
6{
7 std::memset(&_interfacePortPair, 0, sizeof(_interfacePortPair));
8}
9
10
12 : _serverName(other._serverName),
13 _interfacePortPair(other._interfacePortPair),
14 _maxBodySize(other._maxBodySize),
15 _locations(other._locations),
16 _errorPages(other._errorPages)
17{}
18
20{
21 if (this != &other)
22 {
26 _locations = other._locations;
28 }
29 return *this;
30}
31
33
34
35const std::string& ServerConf::getServerName() const
36{
37 return _serverName;
38}
39
40const struct sockaddr_in& ServerConf::getInterfacePortPair() const
41{
42 return _interfacePortPair;
43}
44
46{
47 return _maxBodySize;
48}
49
50const std::vector<LocationConf>& ServerConf::getLocations() const
51{
52 return _locations;
53}
54
55const std::map<std::string, std::string>& ServerConf::getErrorPages() const
56{
57 return _errorPages;
58}
59
60void ServerConf::setServerName(const std::string& name)
61{
62 _serverName = name;
63}
64
65void ServerConf::setInterfacePortPair(const struct sockaddr_in& address)
66{
67 _interfacePortPair = address;
68}
69
71{
72 _maxBodySize = size;
73}
74
76{
77 _locations.push_back(location);
78}
79
80void ServerConf::addErrorPage(const std::string& errorCode, const std::string& errorPagePath)
81{
82 _errorPages[errorCode] = errorPagePath;
83}
84
85std::string ServerConf::getErrorPagePath(const std::string& errorCode) const
86{
87 std::map<std::string, std::string>::const_iterator it = _errorPages.find(errorCode);
88 if (it != _errorPages.end())
89 return it->second;
90 return "";
91}
size_t getMaxBodySize() const
std::string getErrorPagePath(const std::string &errorCode) const
Retrieves the path to a custom error page if one exists.
const struct sockaddr_in & getInterfacePortPair() const
std::string _serverName
void setInterfacePortPair(const struct sockaddr_in &address)
std::vector< LocationConf > _locations
struct sockaddr_in _interfacePortPair
void addErrorPage(const std::string &errorCode, const std::string &errorPagePath)
Adds a custom error page mapping (e.g., "404" -> "/errors/404.html").
std::map< std::string, std::string > _errorPages
void addLocation(const LocationConf &location)
Adds a parsed LocationConf block to this server.
size_t _maxBodySize
const std::vector< LocationConf > & getLocations() const
void setServerName(const std::string &name)
const std::string & getServerName() const
void setMaxBodySize(size_t size)
const std::map< std::string, std::string > & getErrorPages() const
ServerConf & operator=(const ServerConf &other)