Skip to content

Commit

Permalink
Merge pull request #1667 from RotherOSS/issue-#1657-test_patch_and_put
Browse files Browse the repository at this point in the history
Issue #1657: also test PATCH and PUT
  • Loading branch information
bschmalhofer authored Mar 11, 2022
2 parents ad199af + c49846e commit 2ac0879
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions scripts/test/GenericInterface/Provider/Provider.t
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ for my $Test (@Tests) {
#
# Test real HTTP request
#
for my $RequestMethod (qw(get post)) {
for my $RequestMethod (qw(GET POST PATCH PUT)) {

my @BaseURLs = ($ApacheBaseURL);
if ($PlackBaseURL) {
Expand All @@ -414,15 +414,20 @@ for my $Test (@Tests) {
Encode => 1,
);

if ( $RequestMethod eq 'get' ) {
my $UserAgent = LWP::UserAgent->new;

if ( $RequestMethod eq 'GET' ) {
$URL .= "?$QueryString";
$Response = LWP::UserAgent->new()->$RequestMethod($URL);
$Response = $UserAgent->get($URL);
}
else { # POST
$Response = LWP::UserAgent->new()->$RequestMethod(
$URL,
Content => $QueryString
);
elsif ( $RequestMethod eq 'POST' ) {
$Response = $UserAgent->post( $URL, Content => $QueryString );
}
else { # PATCH, PUT

# LWP::UserAgent has no patch() or put() method, use the generic method request()
my $Request = HTTP::Request->new( $RequestMethod, $URL, [], $QueryString );
$Response = $UserAgent->request($Request);
}
chomp( $ResponseData = $Response->decoded_content() );

Expand Down

0 comments on commit 2ac0879

Please sign in to comment.