Curl,  how to recieve data.
    holo via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sun Oct 18 14:01:03 PDT 2015
    
    
  
On Sunday, 18 October 2015 at 20:12:42 UTC, sigod wrote:
> On Sunday, 18 October 2015 at 20:05:24 UTC, holo wrote:
>> @sigod
>>
>> Actually im working on ec2 requests. Thank you  for help, it 
>> is working right now. I don't know why i was trying "+=" 
>> before instead of "~=". Is it good solution to make it such 
>> way?
>
> Not really as it will trigger allocation on every call. Better 
> use [`Appender`][0].
>
> [0]: http://dlang.org/phobos/std_array.html#.Appender
I changed it to such code:
...
             auto client = HTTP(endpoint ~ "?" ~ 
canonicalQueryString);
             client.method = HTTP.Method.get;
             client.addRequestHeader("x-amz-date", xamztime);
             client.addRequestHeader("Authorization", 
authorizationHeader);
             client.onReceive = (ubyte[] 
data){receivedData.put(data); return data.length;};
             client.perform();
             return new Result(receivedData.data);
...
      auto receivedData = appender!string();
...
and it is really much more faster than it was - hope it is what 
you had on your mind.
    
    
More information about the Digitalmars-d-learn
mailing list