mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-05-10 19:48:47 +02:00
「🔥」 PR: added redirection handling #13 from Goat/redirection
This commit is contained in:
38
includes/requests/RedirectResp.hpp
Normal file
38
includes/requests/RedirectResp.hpp
Normal 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
|
@ -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);
|
||||
|
Reference in New Issue
Block a user