| 1 | package RPC::ExtDirect::Server::Patch::HTTPServerSimple; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | no warnings 'redefine'; | ||
| 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 | use HTTP::Server::Simple::CGI::Environment; | ||
| 15 | |||
| 16 | sub HTTP::Server::Simple::CGI::Environment::header { | ||
| 17 | my $self = shift; | ||
| 18 | my $tag = shift; | ||
| 19 | my $value = shift; | ||
| 20 | |||
| 21 | $tag = uc($tag); | ||
| 22 | $tag =~ s/^COOKIES$/COOKIE/; | ||
| 23 | $tag =~ s/-/_/g; | ||
| 24 | $tag = "HTTP_" . $tag | ||
| 25 | unless $tag =~ m/^CONTENT_(?:LENGTH|TYPE)$/; | ||
| 26 | |||
| 27 | if ( exists $ENV{$tag} ) { | ||
| 28 | # This line is fixed | ||
| 29 | $ENV{$tag} .= $tag eq 'HTTP_COOKIE' ? "; $value" : ", $value"; | ||
| 30 | } | ||
| 31 | else { | ||
| 32 | $ENV{$tag} = $value; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | 1; | ||
| 37 |