Skip Menu |

This queue is for tickets about the Net-Async-HTTP CPAN distribution.

Report information
The Basics
Id: 124729
Status: resolved
Priority: 0/
Queue: Net-Async-HTTP

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.42



Subject: SOCKS support
This seems to do the right thing: if( $self->{SOCKS_host} ) { require IO::Async::SOCKS; push @{ $args{extensions} }, "SOCKS"; $args{$_} = $self->{$_} for qw( SOCKS_host SOCKS_port ); } Also consider other SOCKS options, or just passthrough the lot maybe? -- Paul Evans
Better patch applied. Requires updated NaSOCKS via https://rt.cpan.org/Ticket/Display.html?id=124746 -- Paul Evans
Subject: socks-proxy.patch
=== modified file 'lib/Net/Async/HTTP.pm' --- lib/Net/Async/HTTP.pm 2017-02-27 01:01:13 +0000 +++ lib/Net/Async/HTTP.pm 2018-03-09 18:45:31 +0000 @@ -1,7 +1,7 @@ # You may distribute under the terms of either the GNU General Public License # or the Artistic License (the same terms as Perl itself) # -# (C) Paul Evans, 2008-2015 -- leonerd@leonerd.org.uk +# (C) Paul Evans, 2008-2018 -- leonerd@leonerd.org.uk package Net::Async::HTTP; @@ -300,6 +300,12 @@ (either by calling C<request>, or as a result of a redirection) will immediately fail. +=head2 SOCKS_* + +Additionally, any parameters whose names start with C<SOCKS_> will be stored +and used by L<Net::Async::SOCKS> to establish connections via a configured +proxy. + =cut sub configure @@ -319,6 +325,10 @@ $self->{ssl_params}{$_} = delete $params{$_}; } + foreach ( grep { m/^SOCKS_/ } keys %params ) { + $self->{socks_params}{$_} = delete $params{$_}; + } + if( exists $params{ip_tos} ) { # TODO: This conversion should live in IO::Async somewhere my $ip_tos = delete $params{ip_tos}; @@ -362,6 +372,13 @@ my $on_error = $args{on_error}; + if( my $socks_params = $self->{socks_params} ) { + require Net::Async::SOCKS; + + push @{ $args{extensions} }, "SOCKS"; + $args{$_} = $socks_params->{$_} for keys %$socks_params; + } + if( $args{SSL} ) { require IO::Async::SSL; IO::Async::SSL->VERSION( '0.12' ); # 0.12 has ->connect(handle) bugfix