mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
directory file: correct open
This commit is contained in:
@@ -137,7 +137,7 @@ void Response::setCacheControl(void)
|
|||||||
|
|
||||||
void Response::setLocation(void)
|
void Response::setLocation(void)
|
||||||
{
|
{
|
||||||
if (_code == 301)
|
if (_code == 301 && _locationSTR.empty())
|
||||||
{
|
{
|
||||||
_redirect_location = _location->redirect[_code];
|
_redirect_location = _location->redirect[_code];
|
||||||
unsigned long pos = _redirect_location.rfind("$request_file");
|
unsigned long pos = _redirect_location.rfind("$request_file");
|
||||||
@@ -256,6 +256,16 @@ std::string Response::getTime(void)
|
|||||||
return (buff);
|
return (buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Response::directoryFile()
|
||||||
|
{
|
||||||
|
std::string req = _request.getURI();
|
||||||
|
if (req.rfind("/") != req.size() - 1)
|
||||||
|
{
|
||||||
|
_locationSTR = req + "/";
|
||||||
|
_code = 301;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string Response::getFullURI(void)
|
std::string Response::getFullURI(void)
|
||||||
{
|
{
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
@@ -279,12 +289,13 @@ std::string Response::getFullURI(void)
|
|||||||
_upload_dir = _location->uploadDir + tmp;
|
_upload_dir = _location->uploadDir + tmp;
|
||||||
tmp = _location->root + tmp;
|
tmp = _location->root + tmp;
|
||||||
}
|
}
|
||||||
if (_request.isDir(tmp) == 0 && _request.getURI() == _location->location)
|
if (_request.isDir(tmp) == 0)
|
||||||
{
|
{
|
||||||
if (_location->directoryFile.empty() || _Autoindex)
|
if (_location->directoryFile.empty() || _Autoindex)
|
||||||
ret = tmp;
|
ret = tmp;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
directoryFile();
|
||||||
ret = tmp + "/" + _location->directoryFile;
|
ret = tmp + "/" + _location->directoryFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,7 +422,7 @@ bool Response::isRedirect()
|
|||||||
{
|
{
|
||||||
if (_location == NULL)
|
if (_location == NULL)
|
||||||
return (false);
|
return (false);
|
||||||
if (!_location->redirect.empty())
|
if (!_location->redirect.empty() || _code == 301)
|
||||||
{
|
{
|
||||||
_code = 301;
|
_code = 301;
|
||||||
return (true);
|
return (true);
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ private:
|
|||||||
void setLocation(void);
|
void setLocation(void);
|
||||||
void setLanguage(void);
|
void setLanguage(void);
|
||||||
void setTransferEncoding(void);
|
void setTransferEncoding(void);
|
||||||
|
|
||||||
|
void directoryFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map<std::string, std::string> _errorCode;
|
static std::map<std::string, std::string> _errorCode;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user