I've been sitting here the better part of a few hours trying to get a simple POST to a form to work using the LWP module. I've tried a few different ways of building the request, but no matter what I do, I get back a 400 error from apache. Here's the code I'm using now:
my $req = new HTTP::Request POST => '$sitehit';
$req->content_type('application/x-www-form-urlencoded');
$req->content('siteurl=$incoming{\'site\'}');
my $res = $ua->request($req);
print "<br>Result:<br>\n";
print $res->as_string;
$sitehit is defined with a fully qualified URL to a PHP script looking for form input.
$incoming{'site'} is defined with a dummy URL just to give it something to pass to the form.
I have it printing all variables to the screen before it makes it's requests, so I know they are defined properly. Each time I run the script, I get back this:
400 (Bad Request) URL must be absolute
I know it's got to be something simple I overlooked. This is my first attempt at using LWP and the POST method. Any help at all is greatly appreciated.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.