mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 13:27:59 +03:00
add: $request_file
This commit is contained in:
@@ -118,7 +118,16 @@ void Response::setCacheControl(void)
|
||||
void Response::setLocation(void)
|
||||
{
|
||||
if (_code == 301)
|
||||
_locationSTR = _location->redirect[_code];
|
||||
{
|
||||
_redirect_location = _location->redirect[_code];
|
||||
unsigned long pos = _redirect_location.rfind("$request_file");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
_redirect_location.erase(pos);
|
||||
_redirect_location += _request_file;
|
||||
}
|
||||
_locationSTR = _redirect_location;
|
||||
}
|
||||
}
|
||||
|
||||
serverListen Response::getListen()
|
||||
@@ -237,6 +246,7 @@ std::string Response::getFullURI(void)
|
||||
int pos = 0;
|
||||
pos = _request.getURI().rfind("/");
|
||||
tmp = _request.getURI().substr(pos);
|
||||
_request_file = tmp;
|
||||
if (!_location->uploadDir.empty())
|
||||
_upload_dir = _location->uploadDir + tmp;
|
||||
tmp = _location->root + tmp;
|
||||
@@ -244,6 +254,7 @@ std::string Response::getFullURI(void)
|
||||
else
|
||||
{
|
||||
tmp = _request.getURI().substr(len);
|
||||
_request_file = tmp;
|
||||
if (!_location->uploadDir.empty())
|
||||
_upload_dir = _location->uploadDir + tmp;
|
||||
tmp = _location->root + tmp;
|
||||
@@ -380,6 +391,8 @@ void Response::generate2(serverListen &l)
|
||||
|
||||
bool Response::isRedirect()
|
||||
{
|
||||
if (_location == NULL)
|
||||
return (false);
|
||||
if (!_location->redirect.empty())
|
||||
{
|
||||
_code = 301;
|
||||
|
||||
Reference in New Issue
Block a user