Files
cweb/http/http_response.h
cdricms 7b52f5de7d CGI
2024-11-19 16:28:54 +01:00

34 lines
883 B
C

#ifndef HTTP_RESPONSE_H
#define HTTP_RESPONSE_H
#include "http_content_type.h"
#include "http_server.h"
#include "http_status.h"
#include <stdbool.h>
#include <stddef.h>
#include <sys/wait.h>
typedef struct {
HttpStatus status_code;
HttpContentType content_type;
size_t content_length;
char *body;
bool body_in_heap;
} HttpResponse;
// It will create a string respecting the Hypertext Transfer Protocol.
//
// To then be sent to the client.
bool construct_response(HttpResponse __res, char *out);
// Respond a http response to the client (clientfd);
void http_respond(HttpResponse *__res, int clientfd);
// Read a file from a specified path
char *read_file(const char *__path);
// Given a path will return a HttpResponse
HttpResponse *from_file(const char *__path);
void free_response(HttpResponse *__res);
HttpServerRunStatus cgi(const char *__path, int clientfd);
#endif