From eb316d8263df611d4dcdf08b5455059cb6952bd6 Mon Sep 17 00:00:00 2001 From: ihmc3jn09hk Date: Sun, 23 Feb 2020 18:31:27 +0800 Subject: [PATCH] Update Content-Type support for PDF (#361) --- lib/inc/drogon/HttpTypes.h | 1 + lib/src/HttpUtils.cc | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/inc/drogon/HttpTypes.h b/lib/inc/drogon/HttpTypes.h index dada5573..d435715b 100644 --- a/lib/inc/drogon/HttpTypes.h +++ b/lib/inc/drogon/HttpTypes.h @@ -89,6 +89,7 @@ enum ContentType CT_APPLICATION_FONT_WOFF, CT_APPLICATION_FONT_WOFF2, CT_APPLICATION_VND_MS_FONTOBJ, + CT_APPLICATION_PDF, CT_IMAGE_SVG_XML, CT_IMAGE_PNG, CT_IMAGE_JPG, diff --git a/lib/src/HttpUtils.cc b/lib/src/HttpUtils.cc index da4d00a2..91412440 100644 --- a/lib/src/HttpUtils.cc +++ b/lib/src/HttpUtils.cc @@ -106,6 +106,11 @@ const string_view &webContentTypeToString(ContentType contenttype) "Content-Type: application/vnd.ms-fontobject\r\n"; return sv; } + case CT_APPLICATION_PDF: + { + static string_view sv = "Content-Type: application/pdf\r\n"; + return sv; + } case CT_IMAGE_PNG: { static string_view sv = "Content-Type: image/png\r\n"; @@ -443,6 +448,8 @@ ContentType getContentType(const std::string &fileName) case 'p': if (extName == "png") return CT_IMAGE_PNG; + else if(extName == "pdf") + return CT_APPLICATION_PDF; break; case 's': if (extName == "svg")