Files
42_INT_12_webserv/srcs/Client.hpp
LuckyLaszlo 4ab099ee4d redone _read_request(). Should work with any BUFSIZE.
+ WIP in some aspects. Need to adjust parse_request() among others things.
+ update memo.txt
2022-08-07 05:41:01 +02:00

62 lines
1.2 KiB
C++

#ifndef CLIENT_HPP
# define CLIENT_HPP
# include <iostream>
# include <string>
# include <map>
# include <vector>
# include "utils.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;
std::string raw_request;
std::string response;
unsigned int status;
listen_socket *lsocket;
bool header_complete;
size_t read_body_size;
// 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