Hi All,
My question is an extension of this node:
http://www.perlmonks.org/?node_id=248608
I need to use a proxy to login into a website (with my userid/passwd) to post to it.
It is straightforward when one uses the "GET":
#!/usr/bin/perl use LWP::UserAgent; use strict; push(@LWP::Protocol::http::EXTRA_SOCK_OPTS, "LocalPort" => "7000"); my $a = new LWP::UserAgent(); $a->proxy('http', 'http://ofgfw1.owfg.com:8080/'); $a->get("http://mysite.com/");
But let's say I want to use the "POST" in HTTP:Request, in something like:
my $url='mysite.com'; $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave +=> 1)); $req = HTTP::Request->new(POST => 'mysite.com/user_login.php'); $req->content_type('application/x-www-form-urlencoded'); $req->content('username=peter&&passwd=password&&login=yes'); my $res = $ua->request($req); $req = HTTP::Request->new( POST => $url . 'post_something.php' ); $req->content_type('application/x-www-form-urlencoded'); $req->content($data); $res = $ua->request( $req );
I was thinking of doing something like:
$ua->proxy('http', 'http://ofgfw1.owfg.com:8080/'); #???!!!
But my program screams!
How to implement connecting to a proxy with "POST" as opposed to "GET"?
Any hints would be much appreciated.
--
Cheers,
Peter "Excalibur"
In reply to Force LWP to connect to a proxy for HTTP::Request POST by xcalibur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |