dlang-requests 1.1.0 released

Petar Petar
Sun Apr 5 12:26:42 UTC 2020


On Sunday, 5 April 2020 at 11:53:29 UTC, Petar Kirov [ZombineDev] 
wrote:
> On Sunday, 5 April 2020 at 08:59:50 UTC, ikod wrote:
>> Hello!
>>
>> Just a note that dlang-requests ver 1.1.0 released with new 
>> 'ByLine' interfaces added for get/post/put requests.
>>
>> range algorithms can be applied to server responses, so that 
>> simple chain
>>
>> getContentByLine("https://httpbin.org/anything")
>>     .map!"cast(string)a"
>>     .filter!(a => a.canFind("data"))
>>
>> should work.
>>
>> These calls work lazily so you can apply them to large 
>> documents.
>>
>> dlang-requests - HTTP client library, inspired by 
>> python-requests with goals:
>>
>> small memory footprint
>> performance
>> simple, high level API
>> native D implementation
>>
>> https://github.com/ikod/dlang-requests
>> https://code.dlang.org/packages/requests
>>
>> Always waiting for your bugreports and proposals on project 
>> page.
>>
>> Best regards!
>
> Nice work!
>

I noticed that by default trace logging from requests is turned 
on, which is quite verbose. I checked the docs in the readme file 
and at first, I only saw suggestions on how to customize the 
logging by writing a LoggerInterceptor, which I thought was a bit 
too much for casual use. Only after a bit more digging I found 
that you were using std.experimental.logging (e.g. here [1]). 
Later I found that the SSL example in the readme used 
std.experimental.logging [2], but I think it would be better to 
explicitly mention it earlier on, e.g. like this:

/+dub.sdl:
dependency "requests" version="~>1.1"
+/

void main()
{
     import requests : getContentByLine;
     import std : assumeUTF, canFind, each, filter, map, write, 
writeln;

     /*
      * dlang_requests uses `std.experimental.logger` for interal 
logging.
      *
      * The globalLogLevel is set to `LogLevel.all` by default in 
Phobos, which
      * may be too verbose for most applications.
      *
      * This can be changed like this:
      */
     import std.experimental.logger : globalLogLevel, LogLevel;
     globalLogLevel = LogLevel.info;

     getContentByLine("https://httpbin.org/anything")
         .map!assumeUTF
         .filter!(a => a.canFind("data"))
         .each!write;
}


[1]: 
https://github.com/ikod/dlang-requests/blob/v1.1.0/source/requests/streams.d#L383

[2]: 
https://github.com/ikod/dlang-requests/blob/v1.1.0/README.md#ssl-settings


More information about the Digitalmars-d-announce mailing list