There are two issues here:
- changing the http-version: The only way to do this that I have found is to set an Environment Variable
- url-encoding: Just set the content with the content method provided by HTTP::Request
Here is a small example that should do what you wanted:
use strict;
sub BEGIN {
# force HTTP version to 1.0
$ENV{PERL_LWP_USE_HTTP_10} = "1";
}
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
my $ua = new LWP::UserAgent ();
my $req = POST 'http://localhost:4443/test.pl';
$req->content("<user>john\@doe</user>");
print $req->as_string;
my $response = $ua->request($req);
print $response->as_string;
Update:Please be careful when using the "trick" with the Environmant Vaiable, as I have seen it in the code not in any documentation. So I believe that this is an inofficial feature, which could disappear with a new version of LWP.
---- kurt
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.