fix messy code when send_file text#131
Open
bingoohuang wants to merge 4 commits intoTheWaWaR:masterfrom
Open
Conversation
TheWaWaR
reviewed
Mar 15, 2025
| Chinese (Simplified) 你好,世界! (Nǐ hǎo, shìjiè!) | ||
| Russian Здравствуй, мир! (Zdravstvuy, mir!) | ||
| Japanese こんにちは、世界! (Konnichiwa, sekai!) | ||
|
|
TheWaWaR
reviewed
Mar 15, 2025
| } else { | ||
| mime.to_string() | ||
| }; | ||
| resp.headers.set_raw("content-type", vec![content_type.into_bytes()]); |
Owner
There was a problem hiding this comment.
The content-type already set in line:923
TheWaWaR
reviewed
Mar 15, 2025
|
|
||
| // 修复中文乱码问题:对于文本类型的文件,明确指定 UTF-8 编码 | ||
| let content_type = if mime.type_() == "text" { | ||
| format!("{}; charset=utf-8", mime) |
Owner
There was a problem hiding this comment.
If the type is text, first read the content (at most 512 bytes), and use chardet to detect the encoding.
TheWaWaR
reviewed
Mar 15, 2025
| resp.headers | ||
| .set_raw("content-type", vec![mime.to_string().into_bytes()]); | ||
|
|
||
| // 修复中文乱码问题:对于文本类型的文件,明确指定 UTF-8 编码 |
…or text files, addressing non-English character issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.