Protocol-Tus

 view release on metacpan or  search on metacpan

lib/Protocol/Tus/Util.pm  view on Meta::CPAN


sub response_from_exception ($exception, %args) {
   require Protocol::Tus::Response;
   return Protocol::Tus::Response->new_from_exception($exception, %args);
}

sub validate_checksum ($dref, $chk) {
   return unless defined($chk);

   $chk =~ s{\A\s+|\s+\z}{}gmxs;
   my ($type, $expected) = split m{\s+}mxs, $chk, 2;
   ouch 400, 'Bad Request, unsupported checksum algorithm'
      if ($type // '') ne 'sha1';

   $expected //= '';
   my $got = sha1_base64($$dref);
   ouch 460, 'Checksum Mismatch' if $got ne $expected;

   return;
}



( run in 0.522 second using v1.01-cache-2.11-cpan-71847e10f99 )