From b5a395b73d3c6af895a472de7967f8b112f3cb73 Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Mon, 21 Jul 2025 14:14:18 +0300 Subject: [PATCH 1/3] refactor/no-this-capture --- std/net/curl.d | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/std/net/curl.d b/std/net/curl.d index efbb4f8811c..9dfd250357b 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -2425,11 +2425,14 @@ struct HTTP import std.uni : toLower; import std.exception : assumeUnique; + auto self = cast(void*)&this; + // Wrap incoming callback in order to separate http status line from // http headers. On redirected requests there may be several such // status lines. The last one is the one recorded. auto dg = (in char[] header) { + auto this_ = cast(Impl*)self; import std.utf : UTFException; try { @@ -2440,11 +2443,11 @@ struct HTTP } if (header.startsWith("HTTP/")) { - headersIn.clear(); - if (parseStatusLine(header, status)) + this_.headersIn.clear(); + if (parseStatusLine(header, this_.status)) { - if (onReceiveStatusLine != null) - onReceiveStatusLine(status); + if (this_.onReceiveStatusLine != null) + this_.onReceiveStatusLine(this_.status); } return; } @@ -2458,11 +2461,11 @@ struct HTTP { auto io = indexOf(fieldContent, "charset=", No.caseSensitive); if (io != -1) - charset = fieldContent[io + "charset=".length .. $].findSplit(";")[0].idup; + this_.charset = fieldContent[io + "charset=".length .. $].findSplit(";")[0].idup; } if (!m[1].empty && callback !is null) callback(fieldName, fieldContent); - headersIn[fieldName] = fieldContent.idup; + this_.headersIn[fieldName] = fieldContent.idup; } catch (UTFException e) { From 568e61c5ec32b86e177372cc727ed9245829b4eb Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Mon, 21 Jul 2025 14:41:01 +0300 Subject: [PATCH 2/3] fix style --- std/net/curl.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/net/curl.d b/std/net/curl.d index 9dfd250357b..e797e6f3c21 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -2432,7 +2432,7 @@ struct HTTP // status lines. The last one is the one recorded. auto dg = (in char[] header) { - auto this_ = cast(Impl*)self; + auto this_ = cast(Impl*) self; import std.utf : UTFException; try { From 32416af37ad43f3a0421db5f39161f8d4f8a177d Mon Sep 17 00:00:00 2001 From: Sergii Kuzko Date: Mon, 21 Jul 2025 15:42:39 +0300 Subject: [PATCH 3/3] add scope --- std/net/curl.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/net/curl.d b/std/net/curl.d index e797e6f3c21..86fe4bab5c9 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -2425,7 +2425,7 @@ struct HTTP import std.uni : toLower; import std.exception : assumeUnique; - auto self = cast(void*)&this; + scope void* self = cast(void*) &this; // Wrap incoming callback in order to separate http status line from // http headers. On redirected requests there may be several such