Container-Builder
view release on metacpan or search on metacpan
examples/fatpacked.plackup view on Meta::CPAN
}
1;
__END__
=head1 NAME
Plack::Middleware::IIS6ScriptNameFix - fixes wrong SCRIPT_NAME and PATH_INFO that IIS6 sets
=head1 SYNOPSIS
# in your app.psgi
use Plack::Builder;
builder {
enable "IIS6ScriptNameFix";
$app;
};
# Or from the command line
plackup -s FCGI -e 'enable "IIS6ScriptNameFix"' /path/to/app.psgi
=head1 DESCRIPTION
This middleware fixes wrong C<SCRIPT_NAME> and C<PATH_INFO> set by IIS6.
=head1 OPTIONS
=over 4
=item force
By default, this middleware checks if C<SERVER_SOFTWARE> PSGI environment
matches what Microsoft IIS server 6-9 would set for FastCGI. By setting C<force>
to true (1), this middleware always applies the fix, regardless of the
C<SERVER_SOFTWARE> string.
Use this option if the environment is broken similar to IIS, or if the IIS is
updated and the regular expression in this module doesn't match any more
e.g. you're running IIS 10.
=back
=head1 AUTHORS
Florian Ragwitz
=cut
PLACK_MIDDLEWARE_IIS6SCRIPTNAMEFIX
$fatpacked{"Plack/Middleware/IIS7KeepAliveFix.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'PLACK_MIDDLEWARE_IIS7KEEPALIVEFIX';
package Plack::Middleware::IIS7KeepAliveFix;
use strict;
use parent 'Plack::Middleware';
use Plack::Util;
sub call {
my($self, $env) = @_;
# Fixes buffer being cut off on redirect when keep-alive is active
my $res = $self->app->($env);
Plack::Util::response_cb($res, sub {
my $res = shift;
if ($res->[0] =~ m!^30[123]$! ) {
Plack::Util::header_remove($res->[1], 'Content-Length');
Plack::Util::header_remove($res->[1], 'Content-Type');
return sub{ my $chunk; return unless defined $chunk; return ''; };
}
return;
});
}
1;
__END__
=head1 NAME
Plack::Middleware::IIS7KeepAliveFix - fixes buffer being cut off on redirect when keep-alive is active on IIS.
=head1 SYNOPSIS
# in your app.psgi
use Plack::Builder;
builder {
enable "IIS7KeepAliveFix";
$app;
};
# Or from the command line
plackup -s FCGI -e 'enable "IIS7KeepAliveFix"' /path/to/app.psgi
=head1 DESCRIPTION
This middleware fixes buffer being cut off on redirect when keep-alive is active on IIS7.
=head1 AUTHORS
KnowZeroX
=cut
PLACK_MIDDLEWARE_IIS7KEEPALIVEFIX
$fatpacked{"Plack/Middleware/JSONP.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'PLACK_MIDDLEWARE_JSONP';
package Plack::Middleware::JSONP;
use strict;
use parent qw(Plack::Middleware);
use Plack::Util;
use URI::Escape ();
use Plack::Util::Accessor qw/callback_key/;
sub prepare_app {
my $self = shift;
unless (defined $self->callback_key) {
$self->callback_key('callback');
}
}
sub call {
my($self, $env) = @_;
my $res = $self->app->($env);
$self->response_cb($res, sub {
my $res = shift;
if (defined $res->[2]) {
my $h = Plack::Util::headers($res->[1]);
my $callback_key = $self->callback_key;
if ($h->get('Content-Type') =~ m!/(?:json|javascript)! &&
$env->{QUERY_STRING} =~ /(?:^|&)$callback_key=([^&]+)/) {
my $cb = URI::Escape::uri_unescape($1);
if ($cb =~ /^[\w\.\[\]]+$/) {
my $body;
Plack::Util::foreach($res->[2], sub { $body .= $_[0] });
my $jsonp = "/**/$cb($body)";
$res->[2] = [ $jsonp ];
$h->set('Content-Length', length $jsonp);
$h->set('Content-Type', 'text/javascript');
}
}
}
});
}
1;
__END__
=head1 NAME
Plack::Middleware::JSONP - Wraps JSON response in JSONP if callback parameter is specified
=head1 SYNOPSIS
enable "JSONP", callback_key => 'jsonp';
( run in 0.525 second using v1.01-cache-2.11-cpan-df04353d9ac )