add response (with html + css)

This commit is contained in:
2024-11-27 11:33:14 +01:00
parent dc4ef7c7d5
commit 3a6c8ad9a3
11 changed files with 91 additions and 48 deletions

View File

@@ -1,11 +1,7 @@
#ifndef CWS_HTTP_H
#define CWS_HTTP_H
#include <stdio.h> /* Debug */
#include <stdlib.h>
#include <string.h>
#define WWW "../www/" /**< Directory used to get html files */
#define WWW "../www" /**< Directory used to get html files */
/** In the future I'll move conf stuff under a server struct, I can skip just because I want something that works */
#define LOCATION_LEN 1024
#define HTTP_VERSION_LEN 8
@@ -25,6 +21,7 @@ enum http_method {
typedef struct http {
enum http_method method; /**< HTTP request method */
char location[LOCATION_LEN]; /**< Resource requested */
char location_path[LOCATION_LEN]; /**< Resource path */
char http_version[HTTP_VERSION_LEN]; /**< HTTP version */
char user_agent[USER_AGENT_LEN]; /**< User-Agent */
char host[HOST_LEN]; /**< Host */
@@ -42,7 +39,8 @@ typedef struct http {
http_t *http_parse(char *request_str);
void http_parse_method(http_t *request, const char *method);
void http_send_response(http_t *request, int sockfd);
void http_get_content_type(http_t *request, char *content_type);
void http_free(http_t *request);
void http_send_response(http_t *request);
#endif

View File

@@ -16,9 +16,6 @@
#include "utils/hashmap.h"
/* On which port the server will run */
#define PORT 3030
/* Clients max queue */
#define BACKLOG 10
@@ -94,6 +91,4 @@ int handle_new_client(int sockfd, struct sockaddr_storage *their_sa, socklen_t *
*/
void close_fds(bucket_t *bucket);
void send_html_test(int sockfd);
#endif

View File

@@ -11,7 +11,7 @@
/**
* @brief Hash map struct
*
*
*/
typedef struct bucket {
int sockfd; /**< Client socket descriptor */