Plack-App-Proxy-WebSocket

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


    This module is EXPERIMENTAL. I use it in development and it works
    swimmingly for me, but it is completely untested in production
    scenarios.

METHODS

 build_headers_from_env

    Supplement the headers-building logic from Plack::App::Proxy to
    maintain the complete list of proxies in X-Forwarded-For and to set the
    following headers if they are not already set: X-Forwarded-Proto to the
    value of psgi.url_scheme, X-Real-IP to the value of REMOTE_ADDR, and
    Host to the host and port number of a URI (if given).

    This is called internally.

 switching_response_headers

    Like response_headers from Plack::App::Proxy but doesn't filter the
    "Connection" header nor the headers listed by the "Connection" header.

lib/Plack/App/Proxy/WebSocket.pm  view on Meta::CPAN



sub build_headers_from_env {
    my ($self, $env, $req, $uri) = @_;

    my $headers = $self->SUPER::build_headers_from_env($env, $req);

    # if x-forwarded-for already existed, append the remote address; the super
    # method fails to maintain a list of multiple proxies
    if (my $forwarded_for = $env->{HTTP_X_FORWARDED_FOR}) {
        $headers->{'X-Forwarded-For'} = "$forwarded_for, $env->{REMOTE_ADDR}";
    }

    # the super method depends on the user agent to add the host header if it
    # is missing, so set the host if it needs to be set
    if ($uri && !$headers->{'Host'}) {
        $headers->{'Host'} = $uri->host_port;
    }

    $headers->{'X-Forwarded-Proto'} ||= $env->{'psgi.url_scheme'};
    $headers->{'X-Real-IP'} ||= $env->{REMOTE_ADDR};

lib/Plack/App/Proxy/WebSocket.pm  view on Meta::CPAN

agent back-end (which is the default, so no extra configuration is needed).

This module is B<EXPERIMENTAL>.  I use it in development and it works
swimmingly for me, but it is completely untested in production scenarios.

=head1 METHODS

=head2 build_headers_from_env

Supplement the headers-building logic from L<Plack::App::Proxy> to maintain
the complete list of proxies in C<X-Forwarded-For> and to set the following
headers if they are not already set: C<X-Forwarded-Proto> to the value of
C<psgi.url_scheme>, C<X-Real-IP> to the value of C<REMOTE_ADDR>, and C<Host>
to the host and port number of a URI (if given).

This is called internally.

=head2 switching_response_headers

Like C<response_headers> from L<Plack::App::Proxy> but doesn't filter the
"Connection" header nor the headers listed by the "Connection" header.



( run in 0.439 second using v1.01-cache-2.11-cpan-4e96b696675 )