parser.h
1.02 KB
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
#ifndef __HTTP_REQUEST_PARSER_H__
#define __HTTP_REQUEST_PARSER_H__
#include "class.h"
#include "http/request.h"
#include "http/message/queue.h"
#define HTTP_REQUEST_PARSER_READ_CHUNK 1024
#define REMAINS(pars) \
((pars)->buffer_used - ((pars)->cur_data - (pars)->buffer))
typedef enum e_HttpRequestState {
HTTP_REQUEST_GARBAGE=0,
HTTP_REQUEST_START,
HTTP_REQUEST_REQUEST_LINE_DONE,
HTTP_REQUEST_HEADERS_DONE,
HTTP_REQUEST_DONE
} HttpRequestState;
CLASS(HttpRequestParser) {
char * buffer;
char * cur_data;
size_t buffer_used;
size_t buffer_size;
HttpMessageQueue request_queue;
HttpRequest cur_request;
HttpRequestState state;
};
ssize_t httpRequestParserRead(HttpRequestParser, int);
ssize_t httpRequestParserParse(HttpRequestParser);
void httpRequestParserGetBody(HttpRequestParser);
void httpRequestParserGetRequestLine(HttpRequest, char *);
void httpRequestParserGetHeader(HttpRequest, char *);
#endif /* __HTTP_REQUEST_PARSER_H__ */
// vim: set ts=4 sw=4: