| 1 | package LWP::Protocol::socks4; | ||
| 2 | require LWP::Protocol::socks; | ||
| 3 | our @ISA = qw(LWP::Protocol); | ||
| 4 | |||
| 5 | sub request { | ||
| 6 | my($self, $request, $proxy, $arg, $size, $timeout) = @_; | ||
| 7 | my $url = $request->uri; | ||
| 8 | my $scheme = $url->scheme; | ||
| 9 | my $protocol = LWP::Protocol::create("$scheme\::socks", $self->{ua}); | ||
| 10 | $protocol->{proxy_sock_opts} = [ProxyAddr => $proxy->host, | ||
| 11 | ProxyPort => $proxy->port, | ||
| 12 | SocksVersion => 4 | ||
| 13 | ]; | ||
| 14 | |||
| 15 | if ( $proxy->userinfo() ) { | ||
| 16 | push(@{$protocol->{proxy_sock_opts}}, | ||
| 17 | Username => $proxy->user() | ||
| 18 | ); | ||
| 19 | } | ||
| 20 | |||
| 21 | $protocol->request($request, undef, $arg, $size, $timeout); | ||
| 22 | } | ||
| 23 | |||
| 24 | 1; | ||
| 25 | |||
| 26 | __END__ |