www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18446] New: Wrong curl onProgress examples


          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 puremagic.com
          Reporter: andre s-e-a-p.de


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);

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.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);

Feb 15 2018