2013-11-09 16:16:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class HarbormasterHTTPRequestBuildStepImplementation
|
2014-03-26 00:09:21 +01:00
|
|
|
extends HarbormasterBuildStepImplementation {
|
2013-11-09 16:16:12 +01:00
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return pht('Make HTTP Request');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getGenericDescription() {
|
|
|
|
return pht('Make an HTTP request.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
$settings = $this->getSettings();
|
|
|
|
|
|
|
|
$uri = new PhutilURI($settings['uri']);
|
|
|
|
$domain = $uri->getDomain();
|
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
2014-03-13 23:49:42 +01:00
|
|
|
return pht('Make an HTTP %s request to %s', $settings['method'], $domain);
|
2013-11-09 16:16:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(
|
|
|
|
HarbormasterBuild $build,
|
2013-12-05 02:01:12 +01:00
|
|
|
HarbormasterBuildTarget $build_target) {
|
2013-11-09 16:16:12 +01:00
|
|
|
|
|
|
|
$settings = $this->getSettings();
|
2013-12-05 02:01:12 +01:00
|
|
|
$variables = $build_target->getVariables();
|
2013-11-09 16:16:12 +01:00
|
|
|
|
|
|
|
$uri = $this->mergeVariables(
|
|
|
|
'vurisprintf',
|
|
|
|
$settings['uri'],
|
|
|
|
$variables);
|
|
|
|
|
2013-12-05 02:01:12 +01:00
|
|
|
$log_body = $build->createLog($build_target, $uri, 'http-body');
|
2013-11-09 16:16:12 +01:00
|
|
|
$start = $log_body->start();
|
|
|
|
|
2014-03-26 00:08:40 +01:00
|
|
|
$method = nonempty(idx($settings, 'method'), 'POST');
|
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
2014-03-13 23:49:42 +01:00
|
|
|
|
2013-11-09 16:16:12 +01:00
|
|
|
list($status, $body, $headers) = id(new HTTPSFuture($uri))
|
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
2014-03-13 23:49:42 +01:00
|
|
|
->setMethod($method)
|
2013-11-09 16:16:12 +01:00
|
|
|
->setTimeout(60)
|
|
|
|
->resolve();
|
|
|
|
|
|
|
|
$log_body->append($body);
|
|
|
|
$log_body->finalize($start);
|
|
|
|
|
|
|
|
if ($status->getStatusCode() != 200) {
|
|
|
|
$build->setBuildStatus(HarbormasterBuild::STATUS_FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 00:08:40 +01:00
|
|
|
public function getFieldSpecifications() {
|
2013-11-09 16:16:12 +01:00
|
|
|
return array(
|
|
|
|
'uri' => array(
|
2014-03-26 00:08:40 +01:00
|
|
|
'name' => pht('URI'),
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
2013-11-09 16:16:12 +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
2014-03-13 23:49:42 +01:00
|
|
|
'method' => array(
|
2014-03-26 00:08:40 +01:00
|
|
|
'name' => pht('HTTP Method'),
|
|
|
|
'type' => 'select',
|
|
|
|
'options' => array_fuse(array('POST', 'GET', 'PUT', 'DELETE')),
|
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
2014-03-13 23:49:42 +01:00
|
|
|
),
|
2013-11-09 16:16:12 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|