X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-HTTP-AnyUA;a=blobdiff_plain;f=lib%2FHTTP%2FAnyUA%2FUtil.pm;fp=lib%2FHTTP%2FAnyUA%2FUtil.pm;h=3729c56e45029257864f73e00232132e85f5ce24;hp=580b850ddefc951d32bc744808404c421339332f;hb=cde5368e2d23e07a80fa67f670afcb99093d0f77;hpb=8063c6418b41f6e09eb3783f27253502a311f5d8 diff --git a/lib/HTTP/AnyUA/Util.pm b/lib/HTTP/AnyUA/Util.pm index 580b850..3729c56 100644 --- a/lib/HTTP/AnyUA/Util.pm +++ b/lib/HTTP/AnyUA/Util.pm @@ -1,5 +1,5 @@ package HTTP::AnyUA::Util; -# ABSTRACT: Utility subroutines for HTTP::AnyUA backends +# ABSTRACT: Utility subroutines for HTTP::AnyUA backends and middleware use warnings; use strict; @@ -13,6 +13,7 @@ our @EXPORT_OK = qw( http_headers_to_native native_to_http_request coderef_content_to_string + normalize_headers internal_exception http_date parse_http_date @@ -102,6 +103,28 @@ sub http_headers_to_native { return $native; } +=func normalize_headers + + $normalized_headers = normalize_headers(\%headers); + +Normalize headers. Currently lowercases header keys. + +=cut + +sub normalize_headers { + my $headers_in = shift; + + my $headers = {}; + + if (defined $headers_in) { + while (my ($key, $value) = each %{$headers_in || {}}) { + $headers->{lc($key)} = $value; + } + } + + return $headers; +} + =func internal_exception $response = internal_exception($content);