AnyEvent::HTTP::Socks - Adds socks support for AnyEvent::HTTP
use AnyEvent::HTTP; use AnyEvent::HTTP::Socks; http_get 'http://www.google.com/', socks => 'socks5://localhost:1080', sub { print $_[0]; };
This module adds new `socks' option to all http_* functions exported by AnyEvent::HTTP. So you can specify socks proxy for HTTP requests.
This module uses IO::Socket::Socks as socks library, so any global variables like $IO::Socket::Socks::SOCKS_DEBUG can be used to change the behavior.
Socks string structure is:
scheme://login:password@host:port ^^^^^^ ^^^^^^^^^^^^^^ ^^^^ ^^^^ 1 2 3 4
1 - scheme can be one of the: socks4, socks4a, socks5
2 - "login:password@" part can be ommited if no authorization for socks proxy needed. For socks4 proxy "password" should be ommited, because this proxy type doesn't support login/password authentication, login will be interpreted as userid.
3 - ip or hostname of the proxy server
4 - port of the proxy server
You can also make connection through a socks chain. Simply specify several socks proxies in the socks string and devide them by tab(s) or space(s):
"socks4://10.0.0.1:1080 socks5://root:123@10.0.0.2:1080 socks4a://85.224.100.1:9010"
Add socks support to some package based on AnyEvent::HTTP.
Example:
use AnyEvent::HTTP; use AnyEvent::HTTP::Socks; use AnyEvent::Google::PageRank qw(rank_get); use strict; AnyEvent::HTTP::Socks->inject('AnyEvent::Google::PageRank'); rank_get 'http://mail.com', socks => 'socks4://localhost:1080', sub { warn $_[0]; };
You should load AnyEvent::HTTP::Socks after AnyEvent::HTTP, not before. Or simply load only AnyEvent::HTTP::Socks and it will load AnyEvent::HTTP automatically.
AnyEvent::HTTP, IO::Socket::Socks
Oleg G, <oleg@cpan.org>
Copyright (C) 2011 by Oleg G
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself
To install AnyEvent::HTTP::Socks, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::HTTP::Socks
CPAN shell
perl -MCPAN -e shell install AnyEvent::HTTP::Socks
For more information on module installation, please visit the detailed CPAN module installation guide.