[Issue 18446] New: Wrong curl onProgress examples
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 15 20:16:49 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18446
Issue ID: 18446
Summary: Wrong curl onProgress examples
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: minor
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: andre at s-e-a-p.de
https://dlang.org/phobos/std_net_curl.html#.HTTP.onProgress
The example fails to compile because the mismatch ult <-> uln and also the
return 0 statement is missing.
import std.net.curl, std.stdio;
auto client = HTTP("dlang.org");
client.onProgress = delegate int(size_t dl, size_t dln, size_t ul, size_t ult)
{
writeln("Progress: downloaded ", dln, " of ", dl);
writeln("Progress: uploaded ", uln, " of ", ul);
};
client.perform();
https://dlang.org/phobos/std_net_curl.html#.Curl.onProgress
Also this example is wrong and parameters block looks not properly formatted.
curl.perform should be outside the delegate. return 0 is missing. mismatch uln
<-> ulnow
import std.net.curl;
Curl curl;
curl.initialize();
curl.set(CurlOption.url, "http://dlang.org");
curl.onProgress = delegate int(size_t dltotal, size_t dlnow, size_t ultotal,
size_t uln)
{
writeln("Progress: downloaded bytes ", dlnow, " of ", dltotal);
writeln("Progress: uploaded bytes ", ulnow, " of ", ultotal);
curl.perform();
};
--
More information about the Digitalmars-d-bugs
mailing list