Changeset View
Changeset View
Standalone View
Standalone View
src/conduit/ConduitClient.php
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | $data = array( | ||||
// This is a hint to Phabricator that the client expects a Conduit | // This is a hint to Phabricator that the client expects a Conduit | ||||
// response. It is not necessary, but provides better error messages in | // response. It is not necessary, but provides better error messages in | ||||
// some cases. | // some cases. | ||||
'__conduit__' => true, | '__conduit__' => true, | ||||
); | ); | ||||
// Always use the cURL-based HTTPSFuture, for proxy support and other | // Always use the cURL-based HTTPSFuture, for proxy support and other | ||||
// protocol edge cases that HTTPFuture does not support. | // protocol edge cases that HTTPFuture does not support. | ||||
$core_future = new HTTPSFuture($uri, $data); | $core_future = new HTTPSFuture($uri); | ||||
$core_future->addHeader('Host', $this->getHostStringForHeader()); | $core_future->addHeader('Host', $this->getHostStringForHeader()); | ||||
$core_future->setMethod('POST'); | $core_future->setMethod('POST'); | ||||
$core_future->setTimeout($this->timeout); | $core_future->setTimeout($this->timeout); | ||||
// See T13507. If possible, try to compress requests. We always expect | |||||
// Phabricator to be able to accept "Content-Encoding: gzip" requests. | |||||
$can_gzip = function_exists('gzencode'); | |||||
if ($can_gzip) { | |||||
$gzip_data = phutil_build_http_querystring($data); | |||||
$gzip_data = gzencode($gzip_data); | |||||
$core_future->addHeader('Content-Encoding', 'gzip'); | |||||
$core_future->setData($gzip_data); | |||||
} else { | |||||
$core_future->setData($data); | |||||
} | |||||
if ($this->username !== null) { | if ($this->username !== null) { | ||||
$core_future->setHTTPBasicAuthCredentials( | $core_future->setHTTPBasicAuthCredentials( | ||||
$this->username, | $this->username, | ||||
$this->password); | $this->password); | ||||
} | } | ||||
return id(new ConduitFuture($core_future)) | return id(new ConduitFuture($core_future)) | ||||
->setClient($this, $method); | ->setClient($this, $method); | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |