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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.