tdlewis77 has asked for the wisdom of the Perl Monks concerning the following question:
I need to be able to interrupt a pending HTTP::Request without terminating the process. Thanks to some suggestions from Chatterbox, I now have a snippet of code that works.
$ua->add_handler("response_data", sub {croak() if someCondition(); return 1}); my $resp = $ua->get($url);
In my case someCondition() tests a variable that's set in my INT handler so that it aborts the download if the user presses ^C.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interrupting HTTP::Request
by 1nickt (Canon) on Jul 14, 2017 at 11:23 UTC | |
|
Re: Interrupting HTTP::Request
by BrowserUk (Patriarch) on Jul 14, 2017 at 02:13 UTC |