Files
42_INT_12_webserv/srcs/Client.hpp

66 lines
1.3 KiB
C++

#ifndef CLIENT_HPP
# define CLIENT_HPP
# include <iostream>
# include <string>
# include <map>
# include <vector>
# include "utils.hpp"
# include "ServerConfig.hpp"
struct Request
{
http_method method;
std::string path;
std::string version;
std::map<std::string, std::string> headers;
std::string body;
};
class Client
{
public:
Client();
~Client();
//Client(Client const &src);
//Client &operator=(Client const &rhs);
int fd;
const listen_socket *lsocket;
std::string raw_request;
std::string response;
unsigned int status;
bool header_complete;
size_t read_body_size;
ServerConfig *assigned_server; // cant be const cause of error_pages.operator[]
const LocationConfig *assigned_location;
// const functions ?
http_method get_method();
std::string &get_path();
std::string &get_version();
std::string &get_body();
std::string &get_headers(const std::string &key);
void parse_request();
void clear();
void clear_request();
private:
struct Request _request;
void _parse_request_line( std::string rline );
void _parse_request_headers( std::vector<std::string> list );
void _parse_request_body( size_t pos );
};
bool operator==(const Client& lhs, const Client& rhs);
bool operator==(const Client& lhs, int fd);
bool operator==(int fd, const Client& rhs);
#endif