Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions std/net/curl.d
Original file line number Diff line number Diff line change
Expand Up @@ -2425,11 +2425,14 @@ struct HTTP
import std.uni : toLower;
import std.exception : assumeUnique;

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
// status lines. The last one is the one recorded.
auto dg = (in char[] header)
{
auto this_ = cast(Impl*) self;
import std.utf : UTFException;
try
{
Expand All @@ -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;
}
Expand All @@ -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)
{
Expand Down
Loading