fix: 修复静态文件分发时,ContentType类型未设置的bug
This commit is contained in:
1 parent
3626a93e1a
commit
1cb2f76a5e
2 files changed
+2
-1
No files matched your search
@@ -66,7 +66,7 @@ namespace MIN {
|
||||
read(fd, fc->buf.base, fc->buf.len);
|
||||
const char *suffix = strrchr(filepath, '.');
|
||||
if (suffix) {
|
||||
fc->contentType = getContentTypeStrBySuffix(suffix);
|
||||
fc->contentType = getContentTypeStrBySuffix(suffix + 1);
|
||||
}
|
||||
} else if (S_ISDIR(fc->st.st_mode)) {
|
||||
// DIR
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace MIN {
|
||||
response->content = (unsigned char *) fc->buf.base;
|
||||
response->contentLength = fc->buf.len;
|
||||
if (!fc->contentType.empty()) {
|
||||
response->contentType = getMINHttpContentTypeEnumFromStr(fc->contentType);
|
||||
response->headers["Content-Type"] = fc->contentType;
|
||||
}
|
||||
response->headers["Content-Length"] = std::to_string(response->contentLength);
|
||||
|
||||
Reference in new issue
Block a user