Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

How can I stop a POST from url encoding.

by dwatson06 (Friar)
on Jun 28, 2002 at 20:48 UTC ( #178137=perlquestion: print w/replies, xml ) Need Help??

dwatson06 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to create a POST to a CGI script on another server. I am connecting to the server but it can not route the POST because it thinks that 'create_user.cgi' is 'create_user.cgi%20HTTP/1.0'. Also the content is getting url encoded <user>john@doe</user> as %3Cuser%3john%4doe%3enduser%3. I have tried using apostrophe over double quotes, the /, /s, etc... HTTP/1.0 must be passed to the server. Is there a way to force characters in?

$req = POST ' HTTP/1.0' , [ '&lt;user&gt;john@doe&lt;enduser&gt;' ]; print $req->as_string();
Thank you

2002-06-29 Edit by Corion : Moved from QandA, added formatting

Replies are listed 'Best First'.
Re: How can I stop a POST from url encoding.
by amphiplex (Monk) on Jun 29, 2002 at 11:20 UTC
    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/'; $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
Re: How can I stop a POST from url encoding.
by Aristotle (Chancellor) on Jun 29, 2002 at 11:00 UTC
    It can't work that way. I've flipped through the docs, but there seems to be no way to adjust the HTTP version. Looks like you have to fiddle in the innards of the LWP:: modules somewhere - &LWP::Protocol::http::request() seems to be where it's at. That, or &HTTP::Request::as_string() maybe. Or maybe somewhere else - I didn't look for very long.

    Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://178137]
Approved by rob_au
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-12-05 15:40 GMT
Find Nodes?
    Voting Booth?

    No recent polls found