-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.h
More file actions
43 lines (35 loc) · 1.05 KB
/
http.h
File metadata and controls
43 lines (35 loc) · 1.05 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
#ifndef HTTP_H
#define HTTP_H
#include "http11/connection.h"
#include "http11/headers.h"
#include "http11/stringx.h"
typedef struct {
string version;
string method;
string path;
h11_headers* headers;
h11_headers* trailers;
string body;
size_t body_size; // Allocated size of body
} http_request;
typedef struct {
uint16_t status_code;
//string version;
//string reason;
h11_headers* headers;
string body;
} http_response;
typedef void (*http_request_handler)(void* conn, http_request* request);
typedef struct {
int fd;
http_request* request;
http_request_handler handler;
h11_connection* h11_conn;
} http_connection;
http_connection* create_http_connection(int fd, http_request_handler handler);
void destroy_http_connection(http_connection* conn);
int handle_connection(http_connection* conn);
string send_http_request(http_connection* conn, http_request* req);
string send_http_response(http_connection* conn, http_response* res);
void receive_data(http_connection* conn, char* buffer, int len);
#endif