26 |
|
lengthRequired = 411, mediaType = 415, serverError = 500, |
27 |
|
notImplemented, version = 505 }; |
28 |
|
private: |
29 |
+ |
int port; |
30 |
|
virtual int handle(Client* client); |
31 |
|
void headers(istream& sin, Environment& env); |
32 |
|
Status message(istream& sin, Environment& env, ostream& post); |
33 |
|
protected: |
34 |
|
static string crlf; |
35 |
|
string log; |
36 |
< |
Daemon(const string& log) : log(log) {} |
37 |
< |
void serve(int port, bool fork, Daemon* self); |
36 |
> |
Daemon(int port, const string& log) : port(port), log(log) {} |
37 |
> |
void serve(bool fork, Daemon* self); |
38 |
|
istream& getline(istream& sin, string& line) { std::getline(sin, line, |
39 |
|
'\r'); sin.get(); return sin; } |
40 |
|
Status request(istream& sin, Environment& env, ostream& post, ostream& log); |
41 |
|
void response(ostream& sout, Status status); |
42 |
|
string reason(Status status); |
43 |
|
string server(); |
44 |
< |
streamsize error(ostream& sout, Status status); |
44 |
> |
string server(const Environment& env); |
45 |
> |
streamsize error(ostream& sout, Status status, const Environment& env); |
46 |
|
string date(bool log = false); |
47 |
|
public: |
48 |
< |
Daemon(int port, bool fork, const string& log) : log(log) { |
49 |
< |
Person::configure(); serve(port, fork, this); } |
48 |
> |
Daemon(int port, bool fork, const string& log) : port(port), log(log) { |
49 |
> |
Person::configure(); serve(fork, this); } |
50 |
|
virtual ~Daemon() {} |
51 |
|
}; |
52 |
|
|