Thanks for the idea. Thing is, I know how to set the proxy already. The question was how to verify, after the transaction is done, which proxy was used. This becomes less obvious when you're using asynchronous getting, like with a callback or promises.
It turns out that Mojo::Message::Request stores the proxy that was used for the transaction, so that solves this issue. I don't know how I missed that for months. In case anyone else is confused how to do this: assuming a Mojo::UserAgent $ua and a completed Mojo::Transaction $tx, then this will check whether you're still using the proxy which failed. if ( $tx->error) { my $current_proxy = Mojo::URL->new( $ua->proxy->https ); #who uses http these days, it's 2019 if ( $tx->req->proxy eq $current_proxy) { ... #logic for handling the proxy cycling } } As a total aside, why are the 'http' and 'https' attributes of Mojo::UserAgent::Proxy stored as strings and not Mojo::URL? Wouldn't it be more consistent that things which are URL's should be treated as such? On Tue, Jan 8, 2019 at 4:08 PM Илья Рассадин <elcaml...@gmail.com> wrote: > Hi! > > Mojo::UserAgent has proxy attribute. You can set it up request, catch > error and if error is related to proxy, set next proxy and retry request. > On 07/01/2019 12:42, Veesh Goldman wrote: > > I'm working on a project that requires cycling through a list of proxies. > > I've been trying to implement a feature that when a proxy fails to > connect, it switches to the next one. The problem is that I can't figure > out how to tell from a Mojo::Transaction which proxy was used by the > useragent. Any help is appreciated. > > > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To post to this group, send email to mojolicious@googlegroups.com. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To post to this group, send email to mojolicious@googlegroups.com. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.