mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-05-10 19:48:47 +02:00
「🏗️」 wip(requests): requests parsing and basic handling of GET responses
This commit is contained in:
27
includes/requests/HttpRequest.hpp
Normal file
27
includes/requests/HttpRequest.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* HttpRequest.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/03 17:23:00 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/02/03 18:11:29 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#ifndef __REQUESTS_HTTP_REQUEST_HPP__
|
||||
# define __REQUESTS_HTTP_REQUEST_HPP__
|
||||
|
||||
struct HttpRequest {
|
||||
std::string method;
|
||||
std::string target;
|
||||
std::string protocol;
|
||||
std::map<std::string, std::string> headers;
|
||||
std::string body;
|
||||
};
|
||||
|
||||
HttpRequest parseRequest(const std::string &rawRequest);
|
||||
|
||||
#endif
|
38
includes/requests/HttpResponse.hpp
Normal file
38
includes/requests/HttpResponse.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* HttpResponse.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/03 17:21:20 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/02/03 18:11:27 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#ifndef __REQUESTS_HTTP_RESPONSE_HPP__
|
||||
# define __REQUESTS_HTTP_RESPONSE_HPP__
|
||||
|
||||
#include "requests/default.hpp"
|
||||
|
||||
class HttpResponse {
|
||||
public:
|
||||
HttpResponse(const HttpRequest &request);
|
||||
HttpResponse(const HttpResponse &cpy);
|
||||
~HttpResponse(void);
|
||||
|
||||
HttpResponse &operator=(const HttpResponse &cpy);
|
||||
|
||||
std::string str(void) const;
|
||||
|
||||
private:
|
||||
std::string _protocol;
|
||||
size_t _status_code;
|
||||
std::string _status_text;
|
||||
std::map<std::string, std::string> _headers;
|
||||
std::string _body;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
26
includes/requests/default.hpp
Normal file
26
includes/requests/default.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* default.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/03 15:48:22 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/02/03 18:12:58 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#ifndef __REQUESTS_DEFAULT_HPP__
|
||||
# define __REQUESTS_DEFAULT_HPP__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "requests/HttpRequest.hpp"
|
||||
#include "requests/HttpResponse.hpp"
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user