mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Add "HTTPSFuture->addCurlOption()" for raw access to "curl_setopt()"
Summary: Fixes T13533. This is a narrow, fragile API for a particular Kerberos use case on one install. Test Plan: - Set a non-scalar key, got an exception. - Set <"duck", "quack">, got an exception from cURL that the value was invalid. - Set a bunch of made-up options to arbitrary values, no errors. cURL accepts anything so there's nothing we can do about this. - Set `CURLOPT_NOBODY` and saw the request behavior change, demonstrating that the call can produce effects. Maniphest Tasks: T13533 Differential Revision: https://secure.phabricator.com/D21251
This commit is contained in:
parent
6937d38947
commit
b76b9c4065
1 changed files with 36 additions and 0 deletions
|
@ -27,6 +27,8 @@ final class HTTPSFuture extends BaseHTTPFuture {
|
|||
private $parser;
|
||||
private $progressSink;
|
||||
|
||||
private $curlOptions = array();
|
||||
|
||||
/**
|
||||
* Create a temp file containing an SSL cert, and use it for this session.
|
||||
*
|
||||
|
@ -164,6 +166,22 @@ final class HTTPSFuture extends BaseHTTPFuture {
|
|||
return $this->progressSink;
|
||||
}
|
||||
|
||||
/**
|
||||
* See T13533. This supports an install-specific Kerberos workflow.
|
||||
*/
|
||||
public function addCURLOption($option_key, $option_value) {
|
||||
if (!is_scalar($option_key)) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Expected option key passed to "addCurlOption(<key>, ...)" to be '.
|
||||
'a scalar, got "%s".',
|
||||
phutil_describe_type($option_key)));
|
||||
}
|
||||
|
||||
$this->curlOptions[] = array($option_key, $option_value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a file to the request.
|
||||
*
|
||||
|
@ -409,6 +427,24 @@ final class HTTPSFuture extends BaseHTTPFuture {
|
|||
curl_setopt($curl, CURLOPT_PROXY, (string)$proxy);
|
||||
}
|
||||
|
||||
foreach ($this->curlOptions as $curl_option) {
|
||||
list($curl_key, $curl_value) = $curl_option;
|
||||
try {
|
||||
$ok = curl_setopt($curl, $curl_key, $curl_value);
|
||||
if (!$ok) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Call to "curl_setopt(...)" returned "false".'));
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
throw new PhutilProxyException(
|
||||
pht(
|
||||
'Call to "curl_setopt(...) failed for option key "%s".',
|
||||
$curl_key),
|
||||
$ex);
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_download) {
|
||||
$this->downloadHandle = @fopen($this->downloadPath, 'wb+');
|
||||
if (!$this->downloadHandle) {
|
||||
|
|
Loading…
Reference in a new issue