httpRequest.h
1.14 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
46
47
48
49
50
#ifndef __HTTP_REQUEST_H__
#define __HTTP_REQUEST_H__
#define HTTP_REQ_OPTIONS 0
#define HTTP_REQ_GET 1
#define HTTP_REQ_HEAD 2
#define HTTP_REQ_POST 3
#define HTTP_REQ_PUT 4
#define HTTP_REQ_DELETE 5
#define HTTP_REQ_TRACE 6
#define HTTP_REQ_CONNECT 7
extern char httpRequest[8][8];
typedef struct {
char * method;
char * requestUri;
char * httpVersion;
} tRequestLine;
typedef struct {
char * key;
char * value;
} tHttpHeaderLine;
typedef struct {
tRequestLine req;
tHttpHeaderLine * headers;
unsigned int headersCount;
unsigned char bodyLength;
} tHttpHeader;
typedef struct {
tHttpHeader header;
unsigned int length;
char * body;
} tHttpRequest;
int getHttpRequest(char **, unsigned int *, tHttpRequest *);
void freeHttpRequest(tHttpRequest *);
void freeHttpHeader(tHttpHeader *);
unsigned char httpHeaderIsStarted(tHttpHeader *);
int httpHeaderIsComplete(tHttpHeader *);
int httpHeaderGet(char **, unsigned int *, tHttpHeader *);
void httpHeaderParseRequestLine(tHttpHeader *, const char *, unsigned int);
#endif // __HTTP_REQUEST_H__