Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/location test pr #10

Merged
merged 8 commits into from
Jul 30, 2024
Prev Previous commit
Next Next commit
Update: Renamed/unified some methods (HttpResponse, StaticFileHandler)
  • Loading branch information
miooo0o committed Jul 25, 2024
commit 02551e84d3a7ee84f1ee7279d00649521f975cb5
9 changes: 8 additions & 1 deletion src/server/HttpResponse.cpp
Original file line number Diff line number Diff line change
@@ -6,13 +6,20 @@
/* By: minakim <minakim@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/30 16:23:00 by sanghupa #+# #+# */
/* Updated: 2024/07/24 00:08:51 by minakim ### ########.fr */
/* Updated: 2024/07/25 15:40:55 by minakim ### ########.fr */
/* */
/* ************************************************************************** */

#include "webserv.hpp"
#include "HttpResponse.hpp"

////////////////////////////////////////////////////////////////////////////////
/// Your HTTP response status codes must be accurate.
/// You server must have default error pages if none are provided.
/// Limit client body size.
////////////////////////////////////////////////////////////////////////////////


/// @brief Default constructor for the HttpResponse class.
/// Initializes the status code to 200 and the status message to "OK".
HttpResponse::HttpResponse()
9 changes: 5 additions & 4 deletions src/server/StaticFileHandler.cpp
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
/* By: minakim <minakim@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/30 16:23:00 by sanghupa #+# #+# */
/* Updated: 2024/07/24 01:14:50 by minakim ### ########.fr */
/* Updated: 2024/07/25 12:19:31 by minakim ### ########.fr */
/* */
/* ************************************************************************** */

@@ -62,9 +62,9 @@ HttpResponse StaticFileHandler::handleRequest(const HttpRequest& request, const
{
// if (/* && location.location.isListDir() */)
// return (_handleDirListing(request, location));
return (_handleDirRequest(request, location));
return (_handleDirRequest(request, location));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거는 보정이 필요해 보입니다. 탭이 너무 많네요... ㅎ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인하고 수정할게요!

}
else if (isFile(_handledPath))
if (isFile(_handledPath))
return (_handleFileRequest(request, location));
return (_handleNotFound());
}
@@ -83,7 +83,8 @@ HttpResponse StaticFileHandler::_handleDirRequest(const HttpRequest& request, co
_setHandledPath(absolutePath);

std::cout << "TEST | absolute path that with index is built: " << _handledPath << std::endl;

if (isFile(_handledPath))
return (_handleNotFound());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 91: The condition is wrong.

  • I think you wanted to do like this:
if (!isFile(_handledPath))
    return (_handleNotFound());

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 치명적인 실수를. 감사합니다, 수정할게요.

modifiedRequest.setUri(getFullPath());
return (_handleFileRequest(modifiedRequest, location));
}