nicolas-arnaud
2 years ago
10 changed files with 75 additions and 104 deletions
@ -1,42 +1,35 @@ |
|||||
#pragma once |
#pragma once |
||||
#include "webserv.hpp" |
#include "webserv.hpp" |
||||
|
|
||||
typedef std::map< string, std::vector< string > > request_t; |
typedef std::map< string, vec_string > request_t; |
||||
|
|
||||
class Client { |
class Client { |
||||
int _fd; |
int _fd; |
||||
ip_port_t _ip_port; |
ip_port_t _ip_port; |
||||
Master *_parent; |
Master *_parent; |
||||
|
Server *_server; |
||||
string _method; |
Route *_route; |
||||
string _uri; |
string _method, _uri, _host, _header, _body; |
||||
string _host; |
int _len; |
||||
int _len; |
bool _last_chunk; |
||||
bool _last_chunk; |
|
||||
|
|
||||
Server *_server; |
|
||||
Route *_route; |
|
||||
|
|
||||
string _header; |
|
||||
string _body; |
|
||||
request_t _request; |
request_t _request; |
||||
|
|
||||
public: |
|
||||
Client(int fd, ip_port_t ip_port, Master *parent); |
|
||||
~Client(void); |
|
||||
void clean(void); |
void clean(void); |
||||
|
bool getBody(string paquet); |
||||
bool parseHeader(Env *env); |
bool parseHeader(Env *env); |
||||
string header_pick(string key, size_t id); |
string header_pick(string key, size_t id); |
||||
void answer(); |
bool check_method(void); |
||||
bool check_method(); |
|
||||
void create_file(string path); |
void create_file(string path); |
||||
void send_cgi(string cgi, string path); |
void send_cgi(string cgi, string path); |
||||
void send_cgi_redir(string cgi, string path); |
void send_redir(int redir_code, string opt); |
||||
void send_error(int error_code); |
void send_error(int error_code); |
||||
void send_answer(string msg); |
void send_answer(string msg); |
||||
|
|
||||
|
public: |
||||
|
Client(int fd, ip_port_t ip_port, Master *parent); |
||||
|
~Client(void); |
||||
bool getHeader(Env *env, string paquet); |
bool getHeader(Env *env, string paquet); |
||||
bool getBody(string paquet); |
void answer(void); |
||||
|
|
||||
friend class Master; |
friend class Master; |
||||
}; |
}; |
||||
|
@ -1,10 +1,9 @@ |
|||||
#include "webserv.hpp" |
#include "webserv.hpp" |
||||
|
|
||||
void print_block(string name, string content) { |
void print_block(string name, string content) { |
||||
cout << name |
string separator = "|===================================================" |
||||
<< "\n|===================================================" |
"===========================|\n"; |
||||
"===========================|\n" |
cout << name << separator.substr(name.length(), string::npos) << content |
||||
<< content |
<< "\n" |
||||
<< "\n|===========================================================" |
<< separator; |
||||
"===================|\n"; |
|
||||
} |
} |
||||
|
Loading…
Reference in new issue