Skip to content

Commit

Permalink
Merge pull request #162 from ilovenoah/159-set-location-header-when-t…
Browse files Browse the repository at this point in the history
…he-end-of-uri-does-not-have-slash-and-shoud-be-return

Changed the position where the setEntireData function is called to af…
  • Loading branch information
ilovenoah authored Mar 12, 2024
2 parents f636e20 + a5beb71 commit 26e8747
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/response/Response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool Response::_setIndexPage(bool shouldKeepAlive) {
for (std::vector<std::string>::iterator iter = index.begin();
iter != index.end(); ++iter) {
path = this->_actPath + *iter;
this->setEntireDataWithFile(path, "200", shouldKeepAlive);
this->setEntireDataWithFile(path, "200", shouldKeepAlive);
return true;
}
return false;
Expand Down Expand Up @@ -289,10 +289,10 @@ ClientSocket::csphase Response::_setGetResponse(const Request &request) {
}
if (res.getOk() == true &&
this->_actPath.find_last_of('/') != this->_actPath.length() - 1) {
this->setEntireData("301", request.shouldKeepAlive());
this->_headers.insert(std::pair<std::string, std::string>(
"Location",
"http://" + this->_server->getListen() + request.getPath() + "/"));
this->setEntireData("301", request.shouldKeepAlive());
return ClientSocket::SEND;
}
if (res.getOk() == true) {
Expand Down

0 comments on commit 26e8747

Please sign in to comment.