From 94903c884a20cdb5b9e341ced6849f989cae5334 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev <108007295+VPanteleev-S7@users.noreply.github.com> Date: Sat, 29 Mar 2025 10:59:08 +0000 Subject: [PATCH] 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. --- std/net/curl.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/std/net/curl.d b/std/net/curl.d index 07905fc70..efbb4f881 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -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