On Tuesday, 12 May 2020 at 09:56:44 UTC, Pavel Shkadzko 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!
Very nice to see requests for D.
It is written in README that it has a small memory footprint
and performance but how does it compare against Python version?
I never compared performance with Python requests, but I made
some comparisons with
curl and wget, but results were never published. I just checked
that there are no any odd delays.
There were some performance issues with connection pooling and
caching redirects (like
https://github.com/ikod/dlang-requests/issues/80), but they were
fixed quite long ago.
I am asking because we have some Python packages using requests
and I wanted to try to rewrite them in D. To avoid ppl raising
eyebrows it would be nice to know a bit more details if
possible.
There are some functions of Python requests that were not
implemented for dlang - for example, conversion to json and maybe
a few others, but I can easily add them if someone really needs
it.
At the same time I tried to adapt API to Dlang way - like using
lazy ranges when sending or receiving data, and like lazy byLine
interator over response body, so your code may look and perform
better with dlang-requests than with python.
PS. I mentioned small memory footprint in README because, for
some reason, I failed to keep memory usage in reasonable bounds
with std.net.curl at the time I tried to use it.