refactor(worker): use client's connection header

This commit is contained in:
2026-03-25 01:57:12 +01:00
parent e1d928c67e
commit 291596e30a
2 changed files with 29 additions and 10 deletions
+6
View File
@@ -51,12 +51,18 @@ cws_response_s *cws_handler_static_file(cws_request_s *request, cws_handler_conf
return cws_handler_not_found();
}
/* Allocate a response object */
/* @TODO: do not use http 200 ok as default */
cws_response_s *response = cws_response_new(HTTP_OK);
if (!response) {
string_free(filepath);
return cws_response_error(HTTP_INTERNAL_ERROR, "Failed to create response");
}
/* Retrieve Connection header and set it in the response */
const char *conn = cws_request_get_header(request, "Connection");
cws_response_set_header(response, "Connection", conn);
cws_response_set_body_file(response, path);
cws_log_debug("Serving file: %s (%zu bytes)", path, response->content_length);
string_free(filepath);