CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
HTTP Request send literal %2B

 



welch
stranger

Mar 22, 2011, 9:56 AM

Post #1 of 3 (1685 views)
HTTP Request send literal %2B Can't Post

Hi Guys,

I am doing a POST to another server using HTTP::REQUEST and I am sendin an XML string that have in some text node this string: Ws%2BsuHG7Xqk01RaIxm2L/w1L

As you can see the string have %2B and that represents the plus (+) sign in the URL ENCODE and when i do the post the string is converted to: Ws+suHG7Xqk01RaIxm2L/w1L

I can't find a way to send literal %2B... Does any body knows how to do this.

I apreciate your help.

Thanks

welcho
_______________________
Welch


miller
User

Mar 22, 2011, 11:46 AM

Post #2 of 3 (1679 views)
Re: [welch] HTTP Request send literal %2B [In reply to] Can't Post

Use the module URI::Escape or you can roll your own solution to escape the text as well.


Code
use URI::Escape qw(uri_escape); 

my $text = 'Ws%2BsuHG7Xqk01RaIxm2L/w1L';
print uri_escape($text);


or


Code
sub url_escape { 
my $text = shift;
$text =~ s/([^a-z0-9._-~])/sprintf "%%%02X", ord($1)/egi;
$text =~ tr/ /+/;
return $text;
}


- Miller


welch
stranger

Mar 22, 2011, 12:32 PM

Post #3 of 3 (1676 views)
Re: [miller] HTTP Request send literal %2B [In reply to] Can't Post

Thanks Miller i use the second option and work great.
_______________________
Welch

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives