mirror of
https://github.com/opus-tango/http-server-in-c.git
synced 2026-03-20 03:55:25 +00:00
fix argument mismatches between header and c files
This commit is contained in:
@@ -115,7 +115,7 @@ void print_http_response(http_response* res) {
|
|||||||
printf("Body:\n%s\n", (res->body == NULL) ? "" : res->body);
|
printf("Body:\n%s\n", (res->body == NULL) ? "" : res->body);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* reponse_to_string(http_response* res) {
|
char* response_to_string(http_response* res) {
|
||||||
// Define lengths
|
// Define lengths
|
||||||
int total_length = 0;
|
int total_length = 0;
|
||||||
int len_newline = strlen("\r\n");
|
int len_newline = strlen("\r\n");
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ void print_http_response(http_response* res);
|
|||||||
*
|
*
|
||||||
* @return A pointer to the string representation of the response
|
* @return A pointer to the string representation of the response
|
||||||
*/
|
*/
|
||||||
char* reponse_to_string(http_response* res);
|
char* response_to_string(http_response* res);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the value associated with a given key in an http_request's headers.
|
* Finds the value associated with a given key in an http_request's headers.
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ void handle_request(char* request, int length, char* response,
|
|||||||
|
|
||||||
// Create response
|
// Create response
|
||||||
|
|
||||||
// Create reponse string
|
// Create response string
|
||||||
// char* ptr_temp = response;
|
// char* ptr_temp = response;
|
||||||
// char* temp =
|
// char* temp =
|
||||||
// "HTTP/1.1 200 OK\r\nContent-Type: text/html \r\nContent-Length: "
|
// "HTTP/1.1 200 OK\r\nContent-Type: text/html \r\nContent-Length: "
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void response_build_static_file(char* file_path, content_type content_type,
|
|||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
// Read file into buffer
|
// Read file into buffer
|
||||||
unsigned char* file_buffer = (char*)malloc(file_size);
|
char* file_buffer = (char*)malloc(file_size);
|
||||||
if (file_buffer == NULL) {
|
if (file_buffer == NULL) {
|
||||||
printf("malloc failed\n");
|
printf("malloc failed\n");
|
||||||
serve_500(res);
|
serve_500(res);
|
||||||
|
|||||||
@@ -24,10 +24,11 @@ typedef enum {
|
|||||||
|
|
||||||
void response_handle_get(http_request* req, http_response* res);
|
void response_handle_get(http_request* req, http_response* res);
|
||||||
|
|
||||||
char* response_to_string(http_response* res);
|
void response_build_static_file(char* file_path, content_type content_type,
|
||||||
|
status_code status_code, http_response* res);
|
||||||
|
|
||||||
void response_build_static_file(http_request* req, http_response* res);
|
void serve_404(http_response* res);
|
||||||
|
|
||||||
void serve_404(http_request* req, http_response* res);
|
void serve_500(http_response* res);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user