From 2faca00a9a6ac680267a176666d8d588a6026727 Mon Sep 17 00:00:00 2001 From: Sawyer X Date: Thu, 31 Mar 2022 17:30:47 +0200 Subject: [PATCH] Update test and remove lingering keys in request --- lib/Dancer2/Core/App.pm | 9 ++++----- lib/Dancer2/Core/Request.pm | 10 ++++------ t/issues/gh-730.t | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/Dancer2/Core/App.pm b/lib/Dancer2/Core/App.pm index d8453a847..98e418d18 100644 --- a/lib/Dancer2/Core/App.pm +++ b/lib/Dancer2/Core/App.pm @@ -1593,12 +1593,11 @@ sub build_request { # If we have an app, send the serialization engine my $request = Dancer2::Core::Request->new( - env => $env, - is_behind_proxy => $self->settings->{'behind_proxy'} || 0, + env => $env, - $self->has_serializer_engine - ? ( serializer => $self->serializer_engine ) - : (), + $self->has_serializer_engine + ? ( serializer => $self->serializer_engine ) + : (), ); return $request; diff --git a/lib/Dancer2/Core/Request.pm b/lib/Dancer2/Core/Request.pm index e33fd4764..c7b7879ad 100644 --- a/lib/Dancer2/Core/Request.pm +++ b/lib/Dancer2/Core/Request.pm @@ -44,7 +44,7 @@ our $XS_HTTP_COOKIES = eval { require_module('HTTP::XSCookies'); 1; }; our $_id = 0; -# self->new( env => {}, serializer => $s, is_behind_proxy => 0|1 ) +# self->new( env => {}, serializer => $s ) sub new { my ( $class, @args ) = @_; @@ -65,9 +65,8 @@ sub new { } # additionally supported attributes - $self->{'id'} = ++$_id; - $self->{'vars'} = {}; - $self->{'is_behind_proxy'} = !!$opts{'is_behind_proxy'}; + $self->{'id'} = ++$_id; + $self->{'vars'} = {}; $opts{'body_params'} and $self->{'_body_params'} = $opts{'body_params'}; @@ -566,8 +565,7 @@ sub _shallow_clone { $new_request->{headers} = $self->headers; # Copy remaining settings - $new_request->{is_behind_proxy} = $self->{is_behind_proxy}; - $new_request->{vars} = $self->{vars}; + $new_request->{vars} = $self->{vars}; # Clone any existing decoded & cached body params. (GH#1116 GH#1269) $new_request->{'body_parameters'} = $self->body_parameters->clone; diff --git a/t/issues/gh-730.t b/t/issues/gh-730.t index adc519cf1..7c74b11b7 100644 --- a/t/issues/gh-730.t +++ b/t/issues/gh-730.t @@ -8,7 +8,7 @@ use HTTP::Request::Common; package App; use Dancer2; - get '/' => sub { request->is_behind_proxy }; + get '/' => sub { app->config->{'behind_proxy'} }; } my $app = App->to_app;