Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.net.curl doesn't allow to abort a request #10061

Open
dlangBugzillaToGithub opened this issue Jun 12, 2014 · 2 comments
Open

std.net.curl doesn't allow to abort a request #10061

dlangBugzillaToGithub opened this issue Jun 12, 2014 · 2 comments

Comments

@dlangBugzillaToGithub
Copy link

code (@MartinNowak) reported this on 2014-06-12T00:16:10Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=12895

CC List

  • sigod.mail

Description

The official libcurl solution to abort a running HTTP request is to return a non-zero value from the onProgress callback (http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROGRESSFUNCTION).
The problem is that std.net.curl will throw an unspecific CurlException, so the API offers no way to handle that error.

----
import std.net.curl;

void main()
{
    auto http = HTTP("www.example.com");
    http.onProgress = (dltot, dlnow, ultot, ulnow)
    {
        if (dlnow > 1024)
            return 1;
        return 0;
    };
    http.perform();
}
----
std.net.curl.CurlException@std/net/curl.d(3592): Operation was aborted by an application callback on handle 1C94B00
----

I think allowing to pass a boolean to perform() so it returns the error code instead of throwing an error would be a good solution. Note that this is already possible for Curl.perform but not with HTTP.perform, FTP.perform or SMTP.perform.

http://dlang.org/phobos/std_net_curl.html#.Curl.perform
http://dlang.org/phobos/std_net_curl.html#.HTTP.perform
http://dlang.org/phobos/std_net_curl.html#.FTP.perform
http://dlang.org/phobos/std_net_curl.html#.SMTP.perform
@dlangBugzillaToGithub
Copy link
Author

sigod.mail commented on 2015-10-19T21:16:49Z

> Note that this is already possible for Curl.perform but not with HTTP.perform, FTP.perform or SMTP.perform.

Shouldn't this be closed since all of mentioned `perform` functions accept `ThrowOnError` attribute?

@dlangBugzillaToGithub
Copy link
Author

dlang-bugzilla (@CyberShadow) commented on 2017-07-02T02:42:46Z

(In reply to sigod from comment #1)
> Shouldn't this be closed since all of mentioned `perform` functions accept
> `ThrowOnError` attribute?

Martin, ping, is this still actionable?

@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants