62 lines
1.2 KiB
C++
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
|
|
{
|
|
std::map<std::string, std::string> headers;
|
|
std::string method;
|
|
std::string path;
|
|
std::string version;
|
|
std::string body;
|
|
std::string port;
|
|
std::string hostname;
|
|
};
|
|
|
|
class Client
|
|
{
|
|
public:
|
|
Client();
|
|
~Client();
|
|
//Client(Client const &src);
|
|
//Client &operator=(Client const &rhs);
|
|
|
|
int fd;
|
|
std::string port;
|
|
std::string ip;
|
|
std::string raw_request;
|
|
std::string response;
|
|
unsigned int status;
|
|
|
|
std::string get_method();
|
|
std::string get_path();
|
|
std::string get_version();
|
|
std::string get_body();
|
|
std::string get_port();
|
|
std::string get_hostname();
|
|
std::string get_headers(std::string key);
|
|
|
|
void parse_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 );
|
|
void _parse_port_hostname(std::string host);
|
|
|
|
};
|
|
|
|
bool operator==(const Client& lhs, const Client& rhs);
|
|
bool operator==(const Client& lhs, int fd);
|
|
bool operator==(int fd, const Client& rhs);
|
|
|
|
#endif
|