Very, very basic server responses
This commit is contained in:
22
app/main.c
22
app/main.c
@@ -7,7 +7,27 @@
|
||||
|
||||
http_response_t* handle_request(http_request_t* request)
|
||||
{
|
||||
http_response_t* http_response = {};
|
||||
http_response_t* http_response = malloc(sizeof *http_response);
|
||||
http_response->http_version.http_name = "HTTP\0";
|
||||
http_response->http_version.http_name_len = 4;
|
||||
http_response->http_version.major = 1;
|
||||
http_response->http_version.minor = 1;
|
||||
|
||||
http_response->http_status_code = 200;
|
||||
http_response->http_status_message = "OK\0";
|
||||
http_response->http_status_message_len = 2;
|
||||
|
||||
char *length_str = malloc(20);
|
||||
sprintf(length_str, "%ld", request->http_path_len);
|
||||
|
||||
http_response->http_headers = new_hash_map();
|
||||
set(http_response->http_headers, "Server", "SimpleHttpServer");
|
||||
set(http_response->http_headers, "Content-Length", length_str);
|
||||
set(http_response->http_headers, "Content-Type", "text/plain");
|
||||
|
||||
http_response->http_content = request->http_path;
|
||||
http_response->http_content_len = request->http_path_len;
|
||||
|
||||
return http_response;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user