LeftHookRoll
An HTTP/1.0 compliant web server, as specified by RFC1945
Loading...
Searching...
No Matches
LocationConf.cpp
Go to the documentation of this file.
1#include "../includes/LocationConf.hpp"
2
3LocationConf::LocationConf() : _autoIndex(false) {}
4
6 : _path(other._path),
7 _root(other._root),
8 _allowedMethods(other._allowedMethods),
9 _returnURL(other._returnURL),
10 _returnCode(other._returnCode),
11 _autoIndex(other._autoIndex),
12 _defaultPage(other._defaultPage),
13 _storageLocation(other._storageLocation),
14 _cgiInterpreters(other._cgiInterpreters)
15{}
16
18{
19 if (this != &other)
20 {
21 _path = other._path;
22 _root = other._root;
24 _returnURL = other._returnURL;
26 _autoIndex = other._autoIndex;
30 }
31 return *this;
32}
33
35
36
37const std::string& LocationConf::getPath() const
38{
39 return _path;
40}
41const std::string& LocationConf::getRoot() const
42{
43 return _root;
44}
49const std::string& LocationConf::getReturnURL() const
50{
51 return _returnURL;
52}
53const std::string& LocationConf::getReturnCode() const
54{
55 return _returnCode;
56}
58{
59 return _autoIndex;
60}
61const std::string& LocationConf::getDefaultPage() const
62{
63 return _defaultPage;
64}
65const std::string& LocationConf::getStorageLocation() const
66{
67 return _storageLocation;
68}
69
70void LocationConf::setPath(const std::string& path)
71{
72 _path = path;
73}
74void LocationConf::setRoot(const std::string& root)
75{
76 _root = root;
77}
78void LocationConf::setReturnURL(const std::string& url)
79{
80 _returnURL = url;
81}
82void LocationConf::setReturnCode(const std::string& code)
83{
84 _returnCode = code;
85}
86void LocationConf::setAutoIndex(bool autoIndex)
87{
88 _autoIndex = autoIndex;
89}
90void LocationConf::setDefaultPage(const std::string& defaultPage)
91{
92 _defaultPage = defaultPage;
93}
94void LocationConf::setStorageLocation(const std::string& storageLocation)
95{
96 _storageLocation = storageLocation;
97}
98
103
105{
106 return _allowedMethods.isAllowed(method);
107}
108
109std::string LocationConf::getCgiInterpreter(const std::string& ext) const
110{
111 std::map<std::string, std::string>::const_iterator it = _cgiInterpreters.find(ext);
112 if (it != _cgiInterpreters.end())
113 return it->second;
114 return "";
115}
116
117void LocationConf::addCgiInterpreter(const std::string& ext, const std::string& interpreterPath)
118{
119 _cgiInterpreters[ext] = interpreterPath;
120}
121
122bool LocationConf::isCgiExtension(const std::string& ext) const
123{
124 return _cgiInterpreters.find(ext) != _cgiInterpreters.end();
125}
HTTPMethod
Represents the HTTP methods supported by the server as a bitmask.
A lightweight wrapper for a short bitmap to handle HTTP method validations securely.
bool isAllowed(HTTPMethod method) const
Checks if a specific HTTP method is permitted using bitwise AND.
void addMethod(HTTPMethod method)
Adds an HTTP method to the allowed bitmap using bitwise OR.
const std::string & getReturnURL() const
const std::string & getPath() const
std::string getCgiInterpreter(const std::string &ext) const
void setDefaultPage(const std::string &defaultPage)
std::string _root
const std::string & getStorageLocation() const
void addAllowedMethod(HTTPMethod method)
const std::string & getDefaultPage() const
std::string _returnURL
const std::string & getRoot() const
void setAutoIndex(bool autoIndex)
void addCgiInterpreter(const std::string &ext, const std::string &interpreterPath)
std::string _path
const AllowedMethods & getAllowedMethods() const
void setReturnURL(const std::string &url)
bool isMethodAllowed(HTTPMethod method) const
Checks if a specific HTTP method is permitted in this location.
void setReturnCode(const std::string &code)
std::string _returnCode
std::string _defaultPage
bool getAutoIndex() const
std::map< std::string, std::string > _cgiInterpreters
void setRoot(const std::string &root)
const std::string & getReturnCode() const
void setPath(const std::string &path)
void setStorageLocation(const std::string &storageLocation)
bool isCgiExtension(const std::string &ext) const
Checks if a given file extension should be handled by CGI.
LocationConf & operator=(const LocationConf &other)
std::string _storageLocation
AllowedMethods _allowedMethods