Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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
Node Status?
node history
Node Type: perlquestion [id://178137]
Approved by rob_au
beech oh my *me my*
beech cannot replicate
beech stupid 3d printer
[rajesh_perl]: hi
[Discipulus]: good morning monks! or whatever timezone you are experiencing

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2017-03-28 07:16 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (327 votes). Check out past polls.