-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_worker.h
67 lines (45 loc) · 1.17 KB
/
http_worker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef HTTP_WORKER_H
#define HTTP_WORKER_H
#include <iostream>
#include "common.h"
#include "memhunter.h"
class HttpWorker {
// TODO(Janitha): BROKEN WORK IN PROGRESS
private:
public:
enum class HttpState {
START,
FIRSTLINE,
HEADERS,
BODY,
DONE
} http_state;
enum class FirstlineState {
START,
DATA,
DONE
} firstline_state;
MemHunter firstline_crlf_mh;
enum class HeaderState {
START,
DATA,
DONE
} header_state;
MemHunter header_crlfcrlf_mh;
enum class BodyState {
START,
DATA,
DONE
} body_state;
HttpWorker();
virtual ~HttpWorker();
virtual HttpState consume(char *recvbuf, size_t recvlen, size_t &remlen) = 0;
virtual void consume_firstline(char *recvbuf, size_t recvlen, size_t &remlen) = 0;
virtual void consume_header(char *recvbuf, size_t recvlen, size_t &remlen) = 0;
virtual void consume_body(char *recvbuf, size_t recvlen, size_t &remlen) = 0;
};
class HttpServerWorker : public HttpWorker {
HttpServerWorker();
virtual ~HttpServerWorker();
};
#endif