mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
change debug output and add some getters
This commit is contained in:
@@ -27,6 +27,21 @@ void Response::freeData(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Response::getCode()
|
||||||
|
{
|
||||||
|
return (_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t Response::getBodySize()
|
||||||
|
{
|
||||||
|
return _contentLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
location *Response::getLocation(void)
|
||||||
|
{
|
||||||
|
return (_location);
|
||||||
|
}
|
||||||
|
|
||||||
std::string Response::getHeader(void)
|
std::string Response::getHeader(void)
|
||||||
{
|
{
|
||||||
return (*_header);
|
return (*_header);
|
||||||
@@ -82,6 +97,11 @@ void Response::setContentType(void)
|
|||||||
_contentType = getContentType();
|
_contentType = getContentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Response::getRedirect()
|
||||||
|
{
|
||||||
|
return (_locationSTR);
|
||||||
|
}
|
||||||
|
|
||||||
void Response::setContentLength()
|
void Response::setContentLength()
|
||||||
{
|
{
|
||||||
if (_body != NULL)
|
if (_body != NULL)
|
||||||
@@ -272,9 +292,6 @@ std::string Response::getFullURI(void)
|
|||||||
ret = tmp;
|
ret = tmp;
|
||||||
if (_upload_dir.empty())
|
if (_upload_dir.empty())
|
||||||
_upload_dir = ret;
|
_upload_dir = ret;
|
||||||
DBOUT << PINK << "location " << _location->location << ENDL;
|
|
||||||
DBOUT << PINK << "fullURI " << ret << ENDL;
|
|
||||||
DBOUT << PINK << "upload dir " << _upload_dir << ENDL;
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +430,7 @@ void Response::invalidClient(void)
|
|||||||
setHeaderBlocks();
|
setHeaderBlocks();
|
||||||
generateHeader();
|
generateHeader();
|
||||||
|
|
||||||
DBOUT << RED << "Error Method called" << ENDL;
|
DBOUT << WARNING << getDebugTime() << FAIL << " Error Method called" << ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -443,7 +460,8 @@ void Response::methodGet(void)
|
|||||||
generateBody();
|
generateBody();
|
||||||
setHeaderBlocks();
|
setHeaderBlocks();
|
||||||
generateHeader();
|
generateHeader();
|
||||||
DBOUT << GREEN << "GET method called\n" << ZERO_C;
|
DBOUT << WARNING << getDebugTime() << GREEN << " GET Method called" << ENDL;
|
||||||
|
|
||||||
}
|
}
|
||||||
void Response::methodPost(void)
|
void Response::methodPost(void)
|
||||||
{
|
{
|
||||||
@@ -453,7 +471,6 @@ void Response::methodPost(void)
|
|||||||
CgiHandle cgi(_request, *this);
|
CgiHandle cgi(_request, *this);
|
||||||
|
|
||||||
*_body = cgi.executeCgi();
|
*_body = cgi.executeCgi();
|
||||||
DBOUT << "CGI SIZE BODY " << _body->size() << ENDL;
|
|
||||||
unsigned long pos = _body->find("\r\n\r\n");
|
unsigned long pos = _body->find("\r\n\r\n");
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -471,7 +488,8 @@ void Response::methodPost(void)
|
|||||||
_code = 204;
|
_code = 204;
|
||||||
setHeaderBlocks();
|
setHeaderBlocks();
|
||||||
generateHeader();
|
generateHeader();
|
||||||
DBOUT << GREEN << "POST method called" << ENDL;
|
DBOUT << WARNING << getDebugTime() << GREEN << " POST Method called" << ENDL;
|
||||||
|
\
|
||||||
}
|
}
|
||||||
|
|
||||||
void Response::methodPut(void)
|
void Response::methodPut(void)
|
||||||
@@ -495,7 +513,7 @@ void Response::methodPut(void)
|
|||||||
}
|
}
|
||||||
setHeaderBlocks();
|
setHeaderBlocks();
|
||||||
generateHeader();
|
generateHeader();
|
||||||
DBOUT << GREEN << "PUT method called" << ENDL;
|
DBOUT << WARNING << getDebugTime() << GREEN << " PUT Method called" << ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Response::methodDelete(void)
|
void Response::methodDelete(void)
|
||||||
@@ -513,7 +531,7 @@ void Response::methodDelete(void)
|
|||||||
OpenErrorFile(_code);
|
OpenErrorFile(_code);
|
||||||
setHeaderBlocks();
|
setHeaderBlocks();
|
||||||
generateHeader();
|
generateHeader();
|
||||||
DBOUT << GREEN << "Delete method called" << ENDL;
|
DBOUT << WARNING << getDebugTime() << GREEN << " DELETE Method called" << ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ private:
|
|||||||
std::string getContentType(void);
|
std::string getContentType(void);
|
||||||
public:
|
public:
|
||||||
serverListen getListen(void);
|
serverListen getListen(void);
|
||||||
|
location * getLocation(void);
|
||||||
std::string getCgiPass(void);
|
std::string getCgiPass(void);
|
||||||
std::string getHeader(void);
|
std::string getHeader(void);
|
||||||
std::string *getBody(void);
|
std::string *getBody(void);
|
||||||
@@ -71,7 +72,10 @@ public:
|
|||||||
static std::string getReasonPhrase(int);
|
static std::string getReasonPhrase(int);
|
||||||
std::string getErrorPage(int code);
|
std::string getErrorPage(int code);
|
||||||
std::string getFullURI();
|
std::string getFullURI();
|
||||||
ssize_t getMaxBodySize(void);
|
ssize_t getMaxBodySize(void);
|
||||||
|
ssize_t getBodySize();
|
||||||
|
std::string getRedirect();
|
||||||
|
int getCode();
|
||||||
bool isRedirect(void);
|
bool isRedirect(void);
|
||||||
bool allowedMethod(std::string &);
|
bool allowedMethod(std::string &);
|
||||||
void setData(Request, ServerConfig *);
|
void setData(Request, ServerConfig *);
|
||||||
|
|||||||
Reference in New Issue
Block a user