diff --git a/lib/Dancer2/Core/Request.pm b/lib/Dancer2/Core/Request.pm index 7b3a16e3f..c224edc18 100644 --- a/lib/Dancer2/Core/Request.pm +++ b/lib/Dancer2/Core/Request.pm @@ -339,21 +339,8 @@ has body_is_parsed => ( default => sub {0}, ); -has is_behind_proxy => ( - is => 'rw', - isa => Bool, - default => sub {0}, -); - sub host { - my ($self) = @_; - - if ( $self->is_behind_proxy ) { - my @hosts = split /\s*,\s*/, $self->env->{HTTP_X_FORWARDED_HOST}, 2; - return $hosts[0]; - } else { - return $self->env->{'HTTP_HOST'}; - } + return shift->env->{'HTTP_HOST'}; } @@ -427,26 +414,10 @@ Return the scheme of the request =cut - sub scheme { - my ($self) = @_; - my $scheme; - if ( $self->is_behind_proxy ) { - # Note the 'HTTP_' prefix the PSGI spec adds to headers. - $scheme = - $self->env->{'HTTP_X_FORWARDED_PROTOCOL'} - || $self->env->{'HTTP_X_FORWARDED_PROTO'} - || $self->env->{'HTTP_FORWARDED_PROTO'} - || ""; - } - return - $scheme - || $self->env->{'psgi.url_scheme'} - || $self->env->{'PSGI.URL_SCHEME'} - || ""; + return $_[0]->env->{'psgi.url_scheme'} || ""; } - has serializer => ( is => 'ro', isa => Maybe( ConsumerOf ['Dancer2::Core::Role::Serializer'] ), diff --git a/t/request.t b/t/request.t index da315f5fd..8294fab11 100644 --- a/t/request.t +++ b/t/request.t @@ -95,16 +95,6 @@ sub run_test { is $req->base, 'http://oddhostname:5000/foo'; } - note "testing behind proxy"; { - my $req = Dancer2::Core::Request->new( - env => $env, - is_behind_proxy => 1 - ); - is $req->secure, 1; - is $req->host, $env->{HTTP_X_FORWARDED_HOST}; - is $req->scheme, 'https'; - } - note "testing path, dispatch_path and uri_base"; { # Base env used for path, dispatch_path and uri_base tests my $base = {