mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Added 'method' field to the HTTP request build step.
Summary: This revision adds a 'method' field to the HTTP request harbormaster build step. This allows the user to specify GET, POST, DELETE, and PUT (limited by the underlying wrapper phabricator uses for HTTP requests). I'm not sure how much sense PUT makes, but oh well. Existing plans shouldn't break, as if this field is an empty string, we default to POST, which is the old behavior. Fixes T4604 Test Plan: 1) Verified that the empty string does, in fact, issue a POST request. Changed the method to be GET and observed that the problem described in T4604 is resolved. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: aran, epriestley Maniphest Tasks: T4604 Differential Revision: https://secure.phabricator.com/D8520
This commit is contained in:
parent
e6118bcbaf
commit
29436dfe37
1 changed files with 19 additions and 2 deletions
|
@ -16,7 +16,7 @@ final class HarbormasterHTTPRequestBuildStepImplementation
|
|||
|
||||
$uri = new PhutilURI($settings['uri']);
|
||||
$domain = $uri->getDomain();
|
||||
return pht('Make an HTTP request to %s', $domain);
|
||||
return pht('Make an HTTP %s request to %s', $settings['method'], $domain);
|
||||
}
|
||||
|
||||
public function execute(
|
||||
|
@ -34,8 +34,13 @@ final class HarbormasterHTTPRequestBuildStepImplementation
|
|||
$log_body = $build->createLog($build_target, $uri, 'http-body');
|
||||
$start = $log_body->start();
|
||||
|
||||
$method = 'POST';
|
||||
if ($settings['method'] !== '') {
|
||||
$method = $settings['method'];
|
||||
}
|
||||
|
||||
list($status, $body, $headers) = id(new HTTPSFuture($uri))
|
||||
->setMethod('POST')
|
||||
->setMethod($method)
|
||||
->setTimeout(60)
|
||||
->resolve();
|
||||
|
||||
|
@ -54,6 +59,12 @@ final class HarbormasterHTTPRequestBuildStepImplementation
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($settings['method'] === null || $settings['method'] != '' &&
|
||||
!in_array ($settings['method'],
|
||||
array('GET', 'PUT', 'DELETE', 'POST'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -64,6 +75,12 @@ final class HarbormasterHTTPRequestBuildStepImplementation
|
|||
'description' => pht('The URI to request.'),
|
||||
'type' => BuildStepImplementation::SETTING_TYPE_STRING,
|
||||
),
|
||||
'method' => array(
|
||||
'name' => 'Method',
|
||||
'description' =>
|
||||
pht('Request type. Should be GET, POST, PUT, or DELETE.'),
|
||||
'type' => BuildStepImplementation::SETTING_TYPE_STRING,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue