]>
Dogcows Code - chaz/p5-HTTP-AnyUA/blob - lib/HTTP/AnyUA/Middleware/ContentLength.pm
1 package HTTP
::AnyUA
::Middleware
::ContentLength
;
2 # ABSTRACT: Middleware to add Content-Length header automatically
6 $any_ua->apply_middleware('ContentLength');
10 This middleware adds a Content-Length header to the request if the content is known (i.e. the
11 "content" field of the request options is a string instead of a coderef) and if the header is not
17 * L<HTTP::AnyUA::Middleware>
24 our $VERSION = '9999.999'; # VERSION
26 use parent
'HTTP::AnyUA::Middleware';
28 use HTTP
::AnyUA
::Util
;
33 my ($method, $url, $args) = @_;
35 $args->{headers
} = HTTP
::AnyUA
::Util
::normalize_headers
($args->{headers
});
37 if (!defined $args->{headers
}{'content-length'} && $args->{content
} && !ref $args->{content
}) {
38 $args->{headers
}{'content-length'} = length $args->{content
};
41 return $self->backend->request($method, $url, $args);
This page took 0.035254 seconds and 4 git commands to generate.