Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Underscores changed to hyphens by HTTP::Proxy header filter

by Anonymous Monk
on Apr 09, 2009 at 09:55 UTC ( [id://756549]=note: print w/replies, xml ) Need Help??


in reply to Underscores changed to hyphens by HTTP::Proxy header filter

HTTP::Header
#!/usr/bin/perl --- use strict; use warnings; use HTTP::Headers; my $h = HTTP::Headers->new; $h->header( qw' SM_USER waldo '); print $h->as_string; __END__ SM-USER: waldo
http://cpansearch.perl.org/src/GAAS/libwww-perl-5.825/t/base/headers.t
# Check with FALSE $HTML::Headers::TRANSLATE_UNDERSCORE { local($HTTP::Headers::TRANSLATE_UNDERSCORE); $HTTP::Headers::TRANSLATE_UNDERSCORE = undef; # avoid -w warning $h = HTTP::Headers->new; $h->header(abc_abc => "foo"); $h->header("abc-abc" => "bar"); ok($h->header("ABC_ABC"), "foo"); ok($h->header("ABC-ABC"),"bar"); ok($h->remove_header("Abc_Abc")); ok(!defined($h->header("abc_abc"))); ok($h->header("ABC-ABC"), "bar"); }

Replies are listed 'Best First'.
Re^2: Underscores changed to hyphens by HTTP::Proxy header filter
by Anonymous Monk on Apr 09, 2009 at 09:59 UTC
    http://cpansearch.perl.org/src/GAAS/libwww-perl-5.825/Changes
    HTTP::Headers now special case field names that start with a ':'. This is used as an escape mechanism when you need the header names to not go through canonicalization. It means that you can force LWP to use a specific casing and even underscores in header names. The ugly $TRANSLATE_UNDERSCORE global has been undocumented as a result of this.
    seems to work
    #!/usr/bin/perl --- use strict; use warnings; use LWP 5.800; my $h = HTTP::Headers->new; $h->header( qw' :SM_USER waldo '); print $h->as_string; __END__ SM_USER: waldo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://756549]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2024-03-28 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found