forked from tinylcy/vino
-
Notifications
You must be signed in to change notification settings - Fork 1
/
http_request.h
50 lines (38 loc) · 947 Bytes
/
http_request.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
/*
* Copyright(C) Chenyang Li
* Copyright(C) tinyhttpd
*/
#ifndef REQ_MAX_BUF
#define REQ_MAX_BUF 8192
#define HTTP_MAX_BUF 8192
#define HTTP_PARSE_OK 0
#define HTTP_PARSE_AGAIN 1
#define CR '\r'
#define LR '\n'
#define CRLF '\r\n'
#define CRLFCRLF '\r\n\r\n'
#include <stdio.h>
#include <stdlib.h>
typedef struct http_request_s {
int fd;
int epfd;
char buf[REQ_MAX_BUF];
size_t pos;
size_t last;
int status;
char *method_start;
char *method_end;
char *uri_start;
char *uri_end;
char *query_start;
char *query_end;
char *version_start;
char *version_end;
} http_request_t;
void http_request_init(http_request_t *request, int fd, int epfd);
int http_request_parse(http_request_t *request);
char *http_request_get_method(http_request_t *request);
char *http_request_get_uri(http_request_t *request);
char *http_request_get_query(http_request_t *request);
char *http_request_get_version(http_request_t *request);
#endif