mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 21:22:20 +03:00
std.net.curl: Fix fast-path check when encoding is "utf-8" (lower-case) (#10721)
For HTTP, the response body encoding is specified in the "Content-Type" header, e.g.: "Content-Type: application/json; charset=utf-8". MDN says: > - `charset`: Indicates the character encoding standard used. > The value is **case insensitive but lowercase is preferred**. However, `_decodeContent` was comparing the encoding with the exact string "UTF-8", which causes most HTTP requests to go through the slow path. Fix this by using `icmp`, like elsewhere in the module for case-insensitive string comparisons.
This commit is contained in:
parent
1de571c710
commit
94903c884a
1 changed files with 2 additions and 1 deletions
|
@ -1226,9 +1226,10 @@ private auto _decodeContent(T)(ubyte[] content, string encoding)
|
|||
{
|
||||
import std.exception : enforce;
|
||||
import std.format : format;
|
||||
import std.uni : icmp;
|
||||
|
||||
// Optimally just return the utf8 encoded content
|
||||
if (encoding == "UTF-8")
|
||||
if (icmp(encoding, "UTF-8") == 0)
|
||||
return cast(char[])(content);
|
||||
|
||||
// The content has to be re-encoded to utf8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue