client variables are made const
This commit is contained in:
@@ -6,46 +6,68 @@
|
||||
# include <string>
|
||||
# include <map>
|
||||
# include <vector>
|
||||
# include <string.h> // strdup
|
||||
# include "utils.hpp"
|
||||
# include <netinet/in.h> // sockaddr_in, struct in_addr
|
||||
# include <arpa/inet.h> // htonl, htons, ntohl, ntohs, inet_addr, inet_ntoa
|
||||
|
||||
struct Request
|
||||
{
|
||||
std::map<std::string, std::string> headers;
|
||||
std::string method;
|
||||
http_method method;
|
||||
std::string path;
|
||||
std::string version;
|
||||
std::map<std::string, std::string> headers;
|
||||
std::string body;
|
||||
std::string port;
|
||||
std::string hostname;
|
||||
};
|
||||
|
||||
# define MAX_FILESIZE 1000000 // (1Mo)
|
||||
class Client
|
||||
{
|
||||
public:
|
||||
Client();
|
||||
Client(int afd, listen_socket *lsocket, std::string aport, std::string aip);
|
||||
~Client();
|
||||
//Client(Client const &src);
|
||||
//Client &operator=(Client const &rhs);
|
||||
Client(Client const &src);
|
||||
Client &operator=(Client const &rhs);
|
||||
|
||||
int fd;
|
||||
std::string port;
|
||||
std::string ip;
|
||||
std::string raw_request;
|
||||
std::string response;
|
||||
static char buf[MAX_FILESIZE+1];
|
||||
size_t body_size;
|
||||
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);
|
||||
// std::string port;
|
||||
// std::string ip;
|
||||
// listen_socket * lsocket;
|
||||
|
||||
// getters
|
||||
int get_cl_fd() const;
|
||||
std::string get_cl_port() const;
|
||||
std::string get_cl_ip() const;
|
||||
listen_socket * get_cl_lsocket() const;
|
||||
|
||||
// requests getters
|
||||
http_method get_rq_method() const;
|
||||
std::string get_rq_method_str() const;
|
||||
std::string get_rq_path() const;
|
||||
std::string get_rq_version() const;
|
||||
std::string get_rq_body() const;
|
||||
std::string get_rq_port() const;
|
||||
std::string get_rq_hostname() const;
|
||||
std::string get_rq_headers(const std::string & key);
|
||||
|
||||
void parse_request();
|
||||
void clear();
|
||||
void clear_request();
|
||||
|
||||
private:
|
||||
struct Request _request;
|
||||
int _fd;
|
||||
std::string _port;
|
||||
std::string _ip;
|
||||
listen_socket * _lsocket;
|
||||
struct Request _request;
|
||||
|
||||
void _parse_request_line( std::string rline );
|
||||
void _parse_request_headers( std::vector<std::string> list );
|
||||
|
||||
Reference in New Issue
Block a user