From 2be821f32427513b855b95b922b17ada47a2eba9 Mon Sep 17 00:00:00 2001 From: blank X Date: Mon, 17 Jan 2022 16:52:13 +0700 Subject: [PATCH] Set Content-Type --- src/404.cpp | 1 + src/imgurxp.cpp | 7 +++++++ src/proxy_image.cpp | 2 ++ src/utils.cpp | 1 + 4 files changed, 11 insertions(+) diff --git a/src/404.cpp b/src/404.cpp index 00da2b6..b6bc4e1 100644 --- a/src/404.cpp +++ b/src/404.cpp @@ -4,6 +4,7 @@ #include "404.hpp" int not_found(struct http_request* req) { + http_response_header(req, "Content-Type", "text/html"); http_response(req, 404, asset_404_html, asset_len_404_html); return KORE_RESULT_OK; } diff --git a/src/imgurxp.cpp b/src/imgurxp.cpp index 7957973..a49bde4 100644 --- a/src/imgurxp.cpp +++ b/src/imgurxp.cpp @@ -50,6 +50,7 @@ static bool send_hget_and_http_resp(struct http_request* req, const char* id, bo error = "404: album not found"; } std::string error_page = build_error_page(error); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 404, error_page.c_str(), error_page.length()); return true; } @@ -91,6 +92,7 @@ static int album_or_image_start(struct http_request* req) { http_state_cleanup(req); kore_log(LOG_ERR, "failed to initialize curl client"); std::string error_page = build_error_page("Failed to initialize curl client"); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } @@ -139,6 +141,7 @@ static int album_or_image_end(struct http_request* req) { kore_curl_cleanup(client); http_state_cleanup(req); std::string error_page = build_error_page(error.c_str()); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } @@ -153,6 +156,7 @@ static int album_or_image_end(struct http_request* req) { kore_curl_cleanup(client); http_state_cleanup(req); std::string error_page = build_error_page(error.c_str()); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } @@ -174,6 +178,7 @@ static int album_or_image_end(struct http_request* req) { send_hset(id, is_album, ""); } std::string error_page = build_error_page(error.c_str()); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 404, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } @@ -208,6 +213,7 @@ static int album_or_image_end(struct http_request* req) { kore_curl_cleanup(client); http_state_cleanup(req); std::string error_page = build_error_page(error.c_str(), true); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } @@ -219,6 +225,7 @@ static int album_or_image_end(struct http_request* req) { if (error) { kore_log(LOG_ERR, "%s", (*error).c_str()); std::string error_page = build_error_page((*error).c_str()); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } diff --git a/src/proxy_image.cpp b/src/proxy_image.cpp index e7ae637..ae67cb1 100644 --- a/src/proxy_image.cpp +++ b/src/proxy_image.cpp @@ -30,6 +30,7 @@ static int proxy_start(struct http_request* req) { http_state_cleanup(req); kore_log(LOG_ERR, "failed to initialize curl client"); std::string error_page = build_error_page("Failed to initialize curl client"); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } @@ -69,6 +70,7 @@ static int proxy_end(struct http_request* req) { kore_curl_cleanup(client); http_state_cleanup(req); std::string error_page = build_error_page(error.c_str()); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 500, error_page.c_str(), error_page.length()); return HTTP_STATE_COMPLETE; } diff --git a/src/utils.cpp b/src/utils.cpp index 8be3545..8cf4681 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -396,6 +396,7 @@ int send_album_page(struct http_request* req, Album album) { } } response.append(ALBUM_PAGE_END); + http_response_header(req, "Content-Type", "text/html"); http_response(req, 200, response.c_str(), response.length()); return HTTP_STATE_COMPLETE; }