The ini file:
The proxy:[proxy_setup] #port on which proxy listens, use in browser proxy settings port=84 #header to add header_key=SM_USER header_value=waldo
I.e. in the current example, the name of the header entry comes out as "sm-user" instead of "SM_USER". What am I doing wrong?use HTTP::Proxy; use HTTP::Proxy::HeaderFilter::simple; use HTTP::Proxy::Engine::NoFork; use Config::IniFiles; #initialize ini file loading my $ini = 'SM_Proxy.ini'; my $cfg = new Config::IniFiles(-file => $ini); die "invalid ini file $ini" unless defined($cfg); #reads specified config file entry sub read_cfg { my ($section, $key) = @_; my $val = $cfg->val($section, $key); die "undefined key $key in section $section" unless defined($val); $val; } #read values from ini file my $port = read_cfg('proxy_setup', 'port'); my $header_key = read_cfg('proxy_setup', 'header_key'); my $header_value = read_cfg('proxy_setup', 'header_value'); #define proxy and header filter(adding entry read from ini file to eac +h request header) my $proxy = HTTP::Proxy->new( host => "127.0.0.1", port => $port ); my $filter = HTTP::Proxy::HeaderFilter::simple->new( sub { $_[1]->header( $header_key => $header_value); } ); $proxy->push_filter( request => $filter ); $proxy->start;
Update: Thank you guys, using the flag $HTTP::Headers::TRANSLATE_UNDERSCORE solved the issue!
In reply to Underscores changed to hyphens by HTTP::Proxy header filter by jds17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |