fix: 修复静态文件分发时,ContentType类型未设置的bug
This commit is contained in:
@@ -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