File Coverage

blib/lib/RPC/ExtDirect/Server/Patch/HTTPServerSimple.pm
Criterion Covered Total %
statement 12 22 54.5
branch 0 6 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 34 50.0


line stmt bran cond sub pod time code
1             package RPC::ExtDirect::Server::Patch::HTTPServerSimple;
2              
3 7     7   29 use strict;
  7         7  
  7         164  
4 7     7   20 use warnings;
  7         8  
  7         140  
5 7     7   20 no warnings 'redefine';
  7         7  
  7         175  
6              
7             # This monkey patching is required for HTTP::Server::Simple <= 0.51;
8             # CGI.pm < 3.36 does not support HTTP_COOKIE environment variable with
9             # multiple values separated by commas instead of semicolons.
10             #
11             # The code is copied from HTTP::Server::Simple::CGI::Environment,
12             # with a fix applied.
13              
14 7     7   23 use HTTP::Server::Simple::CGI::Environment;
  7         6  
  7         1082  
15              
16             sub HTTP::Server::Simple::CGI::Environment::header {
17 0     0 1   my $self = shift;
18 0           my $tag = shift;
19 0           my $value = shift;
20              
21 0           $tag = uc($tag);
22 0           $tag =~ s/^COOKIES$/COOKIE/;
23 0           $tag =~ s/-/_/g;
24 0 0         $tag = "HTTP_" . $tag
25             unless $tag =~ m/^CONTENT_(?:LENGTH|TYPE)$/;
26              
27 0 0         if ( exists $ENV{$tag} ) {
28             # This line is fixed
29 0 0         $ENV{$tag} .= $tag eq 'HTTP_COOKIE' ? "; $value" : ", $value";
30             }
31             else {
32 0           $ENV{$tag} = $value;
33             }
34             }
35              
36             1;
37