-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_server.h
More file actions
36 lines (20 loc) · 871 Bytes
/
Copy pathhttp_server.h
File metadata and controls
36 lines (20 loc) · 871 Bytes
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
//
// Simple HTTP Server
//
#ifndef HTTPCSERVER_HTTP_SERVER_H
#define HTTPCSERVER_HTTP_SERVER_H
#include <winsock2.h>
#include "ht.h"
#define MAX_HTTP_RECEIVE_SIZE 8192 // every request which has more than this number of bytes is discarded! completely arbitrary number
#define MAX_REQUEST_ROUTE_BUFFER_SIZE 254
typedef int (*callback_function_type)(SOCKET, void*);
typedef struct {
const char* route;
callback_function_type callback_function;
void* callback_function_params; // e.g. the html filepath to be served
} http_route_dispatch;
void handle_client(SOCKET client_socket,struct ht* ht_route_dispatch);
int serve_html_file(SOCKET client_socket, const char* html_file_path);
int serve_image(SOCKET client_socket, const char* image_file_path);
struct http_request parse_incoming_request(char* buffer);
#endif //HTTPCSERVER_HTTP_SERVER_H