Skip to content

fix messy code when send_file text#131

Open
bingoohuang wants to merge 4 commits intoTheWaWaR:masterfrom
bingoohuang:master
Open

fix messy code when send_file text#131
bingoohuang wants to merge 4 commits intoTheWaWaR:masterfrom
bingoohuang:master

Conversation

@bingoohuang
Copy link
Copy Markdown

No description provided.

Comment thread tests/hello.txt
Chinese (Simplified) 你好,世界! (Nǐ hǎo, shìjiè!)
Russian Здравствуй, мир! (Zdravstvuy, mir!)
Japanese こんにちは、世界! (Konnichiwa, sekai!)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is unnecessary.

Comment thread src/main.rs
} else {
mime.to_string()
};
resp.headers.set_raw("content-type", vec![content_type.into_bytes()]);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content-type already set in line:923

Comment thread src/main.rs

// 修复中文乱码问题:对于文本类型的文件,明确指定 UTF-8 编码
let content_type = if mime.type_() == "text" {
format!("{}; charset=utf-8", mime)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the type is text, first read the content (at most 512 bytes), and use chardet to detect the encoding.

Comment thread src/main.rs Outdated
resp.headers
.set_raw("content-type", vec![mime.to_string().into_bytes()]);

// 修复中文乱码问题:对于文本类型的文件,明确指定 UTF-8 编码
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English comment please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants