Skip to content

Commit

Permalink
Item14033: CLI rest using incorrect request object.
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Jun 6, 2016
1 parent c1eff8f commit d42e771
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions core/lib/Foswiki/Engine/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,36 @@ sub prepareHeaders {

sub preparePath {
my ($this) = @_;
my $req = Foswiki::Request->new();

# Create the request. The type of request object is determined by
# the switchboard.

my $action;

if ( $ENV{FOSWIKI_ACTION} ) {
$req->action( $ENV{FOSWIKI_ACTION} );
$action = $ENV{FOSWIKI_ACTION};
}
else {
require File::Spec;
$req->action( ( File::Spec->splitpath($0) )[2] );
$action = ( File::Spec->splitpath($0) )[2];
}

my $dispatcher = $Foswiki::cfg{SwitchBoard}{$action};
my $reqobj =
( defined $dispatcher )
? $dispatcher->{request} || 'Foswiki::Request'
: 'Foswiki::Request';
eval qq(use $reqobj);
die Foswiki::encode_utf8($@) if $@;

my $req = $reqobj->new();
$req->action($action);

if ( exists $this->{path_info} ) {
$req->pathInfo( $this->{path_info} );
delete $this->{path_info};
}

return $req;
}

Expand Down

0 comments on commit d42e771

Please sign in to comment.