Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

lwp-request -H didn't allow repeated headers

This also deal with whitespace before/after the header and and allow
a "User-Agent" value that ends with space to just have it prepended
to the regular value.
  • Loading branch information...
commit fb7a0545931c6b4be436811d097ab951a3b0b434 1 parent 308ca5c
@gisle authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 bin/lwp-request
View
12 bin/lwp-request
@@ -396,9 +396,15 @@ else {
$request = HTTP::Request->new($method);
$request->header('If-Modified-Since', $options{'i'}) if defined $options{'i'};
for my $user_header (@{ $options{'H'} || [] }) {
- my ($header_name, $header_value) = split /:\s*/, $user_header, 2;
- $request->header($header_name, $header_value);
- $ua->agent($header_value) if lc($header_name) eq "user-agent"; # Ugh!
+ my ($header_name, $header_value) = split /\s*:\s*/, $user_header, 2;
+ $header_name =~ s/^\s+//;
+ if (lc($header_name) eq "user-agent") {
+ $header_value .= $ua->agent if $header_value =~ /\s\z/;
+ $ua->agent($header_value);
+ }
+ else {
+ $request->push_header($header_name, $header_value);
+ }
}
#$request->header('Accept', '*/*');
if ($options{'c'}) { # will always be set for request that wants content
Please sign in to comment.
Something went wrong with that request. Please try again.