CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
socket requests trough proxy


New User

Apr 17, 2002, 7:32 AM

Post #1 of 1 (346 views)
socket requests trough proxy Can't Post

Hi, i am using this function to send http requests using socket. now i want to send these requests trough a proxy server, any ideas?

p.s. i cant use LWP for some reasons.

sub send_form {
use Socket;
use URI::Escape;
my $url = $_[0];
my @formular = @{$_[1]}; my $content='';
my ($i,$escaped);
for ($i=0;$i<@formular;$i+=2) {
$escaped = uri_escape($formular[$i+1]);
my $content_type = 'application/x-www-form-urlencoded';
my $content_length = length($content);
my ($host, $uri) = ($url =~ m!http://(.*?)(/.*)!);
my $res;
socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp');
connect SOCK, sockaddr_in(80, inet_aton($host));
send SOCK, "POST $uri HTTP/1.0\r\nHost: $host\r\n" .
"Content-Type: $content_type\r\nContent-Length:" .
"$content_length\r\n\r\n$content", 0;
0 while <SOCK> !~ /^\r\n$/;
$res .= $_ while <SOCK>;
close SOCK;
return $res;

ty for help


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives