-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse.h
More file actions
27 lines (19 loc) · 732 Bytes
/
Copy pathresponse.h
File metadata and controls
27 lines (19 loc) · 732 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
#ifndef RESPONSE_H
#define RESPONSE_H
#include <sys/types.h>
// Response objects which encapsulate all the data necessary for the server to form a request to be directly written
// back to a client. This ensures separation of concerns by letting one module handle all system calls, and another
// module handle request string processing.
typedef struct response_t {
enum response_status_t { HTTP_400, HTTP_404, HTTP_200 } status;
char *header;
char *body_buffer;
int body_fd;
size_t header_size;
off_t body_size;
} response_t;
response_t *response_create_404();
response_t *response_create_200(int fd, const char *mime);
response_t *response_create_400();
void response_free(response_t *res);
#endif