mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
Implement and test --check-spool. Make Mock/UserAgent save put and post data in an array. Make Percona/WebAPI/Client accept ready-made text resources, for multi-part resources.
This commit is contained in:
@@ -31,8 +31,8 @@ sub new {
|
||||
put => [],
|
||||
},
|
||||
content => {
|
||||
post => undef,
|
||||
put => undef,
|
||||
post => [],
|
||||
put => [],
|
||||
},
|
||||
};
|
||||
return bless $self, $class;
|
||||
@@ -42,7 +42,7 @@ sub request {
|
||||
my ($self, $req) = @_;
|
||||
my $type = lc($req->method);
|
||||
if ( $type eq 'post' || $type eq 'put' ) {
|
||||
$self->{content}->{$type} = $req->content;
|
||||
push @{$self->{content}->{$type}}, $req->content;
|
||||
}
|
||||
my $r = shift @{$self->{responses}->{$type}};
|
||||
my $c = $self->{encode}->($r->{content});
|
||||
|
@@ -233,12 +233,17 @@ sub _set {
|
||||
my $res = $args{resources};
|
||||
my $url = $args{url};
|
||||
|
||||
my $content;
|
||||
my $content = '';
|
||||
if ( ref($res) eq 'ARRAY' ) {
|
||||
PTDEBUG && _d('List of resources');
|
||||
$content = '[' . join(",\n", map { as_json($_) } @$res) . ']';
|
||||
}
|
||||
elsif ( -f $res ) {
|
||||
PTDEBUG && _d('Reading content from file', $res);
|
||||
elsif ( ref($res) ) {
|
||||
PTDEBUG && _d('Resource object');
|
||||
$content = as_json($res);
|
||||
}
|
||||
elsif ( $res !~ m/\n/ && -f $res ) {
|
||||
PTDEBUG && _d('List of resources in file', $res);
|
||||
$content = '[';
|
||||
my $data = do {
|
||||
local $INPUT_RECORD_SEPARATOR = undef;
|
||||
@@ -250,7 +255,8 @@ sub _set {
|
||||
$content .= $data;
|
||||
}
|
||||
else {
|
||||
$content = as_json($res);
|
||||
PTDEBUG && _d('Resource text');
|
||||
$content = $res;
|
||||
}
|
||||
|
||||
eval {
|
||||
|
Reference in New Issue
Block a user