Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.117.149.93
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : IIS7KeepAliveFix.pm
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

© 2025 GrazzMean