」 feat: added redirection handling

This commit is contained in:
2025-05-04 13:37:49 +02:00
parent 1537cf59ac
commit 4f93e0dcf5
4 changed files with 64 additions and 21 deletions

View File

@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* RedirectResp.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/04 13:12:04 by adjoly #+# #+# */
/* Updated: 2025/05/04 13:33:36 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <requests/Response.hpp>
namespace webserv {
namespace http {
class Redirect : public Response {
public:
Redirect(std::string redir_path) : _path(redir_path) {
setProtocol("HTTP/1.1");
setStatusCode(308);
addHeader("Location", _path);
addHeader("Content-lengh", "0");
}
void setPath(const std::string path) { _path = path; }
std::string getPath(void) const { return _path; }
~Redirect(void) {}
protected:
private:
std::string _path;
};
} // namespace http
} // namespace webserv

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 17:21:20 by mmoussou #+# #+# */
/* Updated: 2025/04/30 09:33:47 by adjoly ### ########.fr */
/* Updated: 2025/05/04 13:12:53 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,7 @@ typedef unsigned int uint;
namespace webserv {
namespace http {
class Response : public http::IMessage {
class Response : public IMessage {
public:
Response(void);
~Response(void);