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: Intermediate:
"HTTP::Headers" error on apostrophe in URL

 



Bucz
Novice

May 2, 2009, 3:32 PM

Post #1 of 8 (3988 views)
"HTTP::Headers" error on apostrophe in URL Can't Post

Hello,

a strange error I get when trying to invoke LWP UserAgernt:

Can't locate object method "sprint" via package "HTTP::Headers" at /Library/Perl/5.8.8/HTTP/Message.pm line 536.

I just figured out that it occurs when I add an apostrophe to the URL:

this is OK:
$req->content("id=1002")

this is errorous (%27 is an apostrophe ' )
$req->content("id=1002 %27")

I have just updated packages with CPAN so it should go OK. I user the most simple standard code to test UserAgent

I use Mac OS 10.5 if it makes a difference

Any ideas?


(This post was edited by Bucz on May 2, 2009, 4:12 PM)


KevinR
Veteran


May 2, 2009, 4:27 PM

Post #2 of 8 (3983 views)
Re: [Bucz] "HTTP::Headers" error on apostrophe in URL [In reply to] Can't Post

if you literally need to pass a percent sign try %25:


Code
$req->content('id=1002%20%2527')


note %20 is a space and %25 is the percent symbol.
-------------------------------------------------


Bucz
Novice

May 3, 2009, 3:13 AM

Post #3 of 8 (3977 views)
Re: [KevinR] "HTTP::Headers" error on apostrophe in URL [In reply to] Can't Post

hi,

i need to pass apostrophe that is %27, so still no clue


FishMonger
Veteran / Moderator

May 3, 2009, 5:37 AM

Post #4 of 8 (3967 views)
Re: [Bucz] "HTTP::Headers" error on apostrophe in URL [In reply to] Can't Post

Have you tried using single quotes instead of double quotes? The double quotes causes variable interpolation, which in this case you don't want.

change it to:
$req->content('id=1002 %27')

or:
$req->content('id=1002%20%27')


(This post was edited by FishMonger on May 3, 2009, 5:37 AM)


KevinR
Veteran


May 3, 2009, 10:06 AM

Post #5 of 8 (3962 views)
Re: [FishMonger] "HTTP::Headers" error on apostrophe in URL [In reply to] Can't Post


In Reply To
Have you tried using single quotes instead of double quotes? The double quotes causes variable interpolation, which in this case you don't want.

change it to:
$req->content('id=1002 %27')

or:
$req->content('id=1002%20%27')


There is no variable interpolation in that string though. Only scalars and arrays are converted to strings inside of double-quotes. Using the correct quotes is always a good idea though.
-------------------------------------------------


FishMonger
Veteran / Moderator

May 3, 2009, 10:27 AM

Post #6 of 8 (3961 views)
Re: [KevinR] "HTTP::Headers" error on apostrophe in URL [In reply to] Can't Post

My bad...I should have done a copy/paste.

The original post had used double quotes which would have caused a problem with %27 because Perl would have attempted to interpolate that as a hash and if running under strictures, that would cause a compilation error. I'll leave it to the reader to determine why it would be a compilation error.


Quote
Can't use global %27 in my at ...


My bad, again.

Yes Kevin, you're right. I forgot that fact.



(This post was edited by FishMonger on May 3, 2009, 10:30 AM)


KevinR
Veteran


May 3, 2009, 10:35 AM

Post #7 of 8 (3958 views)
Re: [FishMonger] "HTTP::Headers" error on apostrophe in URL [In reply to] Can't Post

Maybe I am miss-understanding something, but hashes inside of quotes, even double-quotes, are not subject to interpolation/expansion:


Code
use strict; 
use warnings;

print "this is a %27 test";


Only scalars, arrays and meta sequences are.
-------------------------------------------------


KevinR
Veteran


May 3, 2009, 10:39 AM

Post #8 of 8 (3956 views)
Re: [Bucz] "HTTP::Headers" error on apostrophe in URL [In reply to] Can't Post


In Reply To
hi,

i need to pass apostrophe that is %27, so still no clue


then maybe:

$req->content(q{id=1002 '})
-------------------------------------------------

 
 


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

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