Curl, how to recieve data.

sigod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 18 11:55:50 PDT 2015


On Sunday, 18 October 2015 at 18:04:53 UTC, holo wrote:
> I'm trying to receive data from curl request my sample code 
> looks like that:
>
> ...
>             auto client = HTTP(endpoint ~ "?" ~ 
> canonicalQueryString);
>             client.method = HTTP.Method.get;
>             client.addRequestHeader("x-amz-date", xamztime);
>             client.addRequestHeader("Authorization", 
> authorizationHeader);
>             client.onReceive = (ubyte[] data)
>             {
>                 recievedData = data;
>                 return data.length;
>             };
>             client.perform();
>
>             return new Result(recievedData);
> ...
>
>             ubyte[] receivedData;
>
> ...
>
> but im getting only last (like from "tail" command in unix 
> systems) part of data which im expecting.
>
> How to receive and save whole data which came as feedback for 
> request? Or is there some other way to access it after usage of 
> client.perform method?

I believe `onReceive` called multiple times with chunks of 
received data. So, you need to use `Appender` or `~`.

A bit off-topic:
Are you trying to download file from S3? It seems I should really 
start working on my S3 library...


More information about the Digitalmars-d-learn mailing list