-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseUtils.h
More file actions
32 lines (21 loc) · 978 Bytes
/
parseUtils.h
File metadata and controls
32 lines (21 loc) · 978 Bytes
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
//#include <assert.h>
//#include <stdio.h>
//#include <stdlib.h>
//#include <unistd.h>
#ifndef PARSE_UTILS 201411251555
#include <stdio.h>
#include <stdlib.h>
#define BUFFER_SIZE 4096
enum CHECK_STATE { CHECK_STATE_REQUESTLINE = 0, CHECK_STATE_HEADER, CHECK_STATE_CONTENT };
enum LINE_STATUS { LINE_OK = 0, LINE_BAD, LINE_OPEN };
enum HTTP_CODE { NO_REQUEST, GET_REQUEST, BAD_REQUEST, FORBIDDEN_REQUEST, INTERNAL_ERROR, CLOSED_CONNECTION };
static const char* szret[] = { "I get a correct result\n", "Something wrong\n" };
/* 从状态机,用于分析一行的内容 */
lINE_STATUS parse_line( char* buffer, int& checked_index, int& read_index );
/* 分析请求行 */
HTTP_CODE parse_requestline( char* temp, CHECK_STATE& checkstate );
/* 分析头部字段 */
HTTP_CODE parse_headers( char* temp );
/* 分析http请求的入口函数 */
HTTP_CODE parse_content( char* buffer, int& checked_index, CHECK_STATE& checkstate, int& read_index, int& start_line);
#endif