Curl wrapper round two

jdrewsen jdrewsen at nospam.com
Sun Jun 19 03:07:21 PDT 2011


Den 19-06-2011 11:08, Johannes Pfau skrev:
> jdrewsen wrote:
>> Hi,
>>
>>     I've finally got through all the very constructive comments from
>> the
>> last review of the curl wrapper and performed the needed changes.
>>
>> Here is the github branch:
>> https://github.com/jcd/phobos/tree/curl-wrapper
>>
>> And the generated docs:
>> http://freeze.steamwinter.com/D/web/phobos/etc_curl.html
>>
>> I do have some problems getting ddoc to show the documentation of
>> mixins. So in order to view the doc for byLine/byChunk methods you
>> have to look at the source.
>
> That's bad because lots of useful stuff hides in the protocol mixin.
> The url property for example is essential for keep-alive requests, but
> it doesn't show up in the documentation :-(

I agree. And also in the ByLineAsync etc. mixins. I would very much like 
to get a hint on how to do it if anyone knows.

> Also, a keep alive example would be great:
> --------------------------------------------
> auto client = Http("http://api.vevo.com/mobile/v2/authentication.json");
> client.addHeader("User-Agent", "Android API Connector");
> client.addHeader("Connection", "Keep-Alive");
> client.method = Http.Method.post;
> client.onReceive = (ubyte[] data) { write(cast(char[])data); return
> data.length; };
> client.postData = "p=android&v=1.05";
> client.perform();
>
> //2nd request
> client.url = "http://api.vevo.com/mobile/v1/featured/carousel.json";
> client.method = Http.Method.get;
> client.perform();
> --------------------------------------------
> Maybe something like this. (+points if the code uses existing
> websites)

I'll include that. And I need a "header(key, value)" parameter on 
Http.(Async)Result as well. That way your example could be written:

auto r = Http.post("http://api.vevo.com/mobile/v2/authentication.json",
                    "p=android&v=1.05")
                    .header("User-Agent", "Android API Connector")
                    .header("Connection", "Keep-Alive"));
write(r.bytes);

> BTW: The curl verbose output is great. I guess it won't
> be activated in phobos by default, but is it possible to activate it
> manually? If so, this very useful feature should be documented.

Yes - verbose should be made in a property by itself.

Thank you for the comments!
/Jonas



More information about the Digitalmars-d mailing list