-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.h
62 lines (53 loc) · 1.25 KB
/
http.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
/* http.h */
/* Part of hhttppss, a simple HTTP server skeleton
* Author: Berke Durak
* Released in the public domain
*/
#ifndef HTTP_H
#define HTTP_H
#include <sys/socket.h>
#include <netinet/in.h>
#include "server.h"
#include "demux.h"
#include "writer.h"
#include "lines.h"
#include "resource.h"
typedef enum {
HTTP_REQUEST,
HTTP_HEADER,
HTTP_MORE_HEADERS,
HTTP_BUILD_RESPONSE,
HTTP_RESPONDING,
HTTP_RESPONSE_ONLY,
HTTP_SERVING
} http_state;
typedef struct {
int hrl_allocated;
char *hrl_method;
char *hrl_uri;
char *hrl_major;
char *hrl_minor;
} http_request_line;
typedef struct {
int hhl_allocated;
char *hhl_name;
lines *hhl_value;
} http_header_line;
typedef struct {
server *ht_server;
connection *ht_connection;
lines *ht_lines;
struct sockaddr_in ht_sockaddr;
http_state ht_state;
char *ht_response; /* Allocated HTTP response. */
http_request_line ht_hrl;
http_header_line ht_hhl;
writer *ht_writer;
resource *ht_resource;
} http;
http *http_create(server *sv, connection *cn, struct sockaddr_in *sa);
void http_delete(http *ht);
void http_add_bytes(http *ht, char *p, int m);
void http_connection_handler(void *svd, connection *cn, short events);
void http_connection_delete(void *svd, connection *cn);
#endif