-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpserver.h
More file actions
47 lines (42 loc) · 1.17 KB
/
Copy pathhttpserver.h
File metadata and controls
47 lines (42 loc) · 1.17 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
#ifndef HTTPHEADER_H
#define HTTPHEADER_H
#include <stdint.h>
#include <stddef.h>
#include "queue.h"
extern queue *job_queue;
typedef struct job {
int client_fd;
} job_t;
typedef struct {
char method[16];
char uri[128];
char version[20];
char header_key[256];
char header_value[256];
int request_id;
uint8_t *body;
size_t body_length;
} http_request_t;
typedef struct {
char header_key[256];
char header_value[256];
char version[20];
char *status_phrase;
int status;
uint8_t *body;
size_t body_length;
} http_response_t;
int create_socket(int port);
int accept_connection(int server_fd);
int parse_request(int client_fd, http_request_t *req);
void close_connection(int client_addr);
void *worker(void *arg);
void enqueue(int client_fd);
int dequeue(void);
static void set_body_text(http_response_t *rep, const char *text);
int exec_get(http_request_t *req, http_response_t *rep);
int exec_put(http_request_t *req, http_response_t *rep);
void send_response(int client_fd, http_response_t *rep);
void log_request(http_request_t *req, http_response_t *rep);
int handle_request(http_request_t *req, http_response_t *rep);
#endif