public function callMethod($method, array $params) { $meta = array(); if ($this->sessionKey) { $meta['sessionKey'] = $this->sessionKey; } if ($this->connectionID) { $meta['connectionID'] = $this->connectionID; } if ($method == 'conduit.connect') { $certificate = idx($params, 'certificate'); if ($certificate) { $token = time(); $params['authToken'] = $token; $params['authSignature'] = sha1($token . $certificate); } unset($params['certificate']); } if ($meta) { $params['__conduit__'] = $meta; } $uri = id(clone $this->uri)->setPath('/api/' . $method); $data = array('params' => json_encode($params), 'output' => 'json', '__conduit__' => true); // Always use the cURL-based HTTPSFuture, for proxy support and other // protocol edge cases that HTTPFuture does not support. $core_future = new HTTPSFuture($uri, $data); $core_future->setMethod('POST'); $core_future->setTimeout($this->timeout); if ($this->username !== null) { $core_future->setHTTPBasicAuthCredentials($this->username, $this->password); } $conduit_future = new ConduitFuture($core_future); $conduit_future->setClient($this, $method); $conduit_future->beginProfile($data); $conduit_future->isReady(); return $conduit_future; }
public function callMethod($method, array $params) { $meta = array(); if ($this->sessionKey) { $meta['sessionKey'] = $this->sessionKey; } if ($this->connectionID) { $meta['connectionID'] = $this->connectionID; } if ($method == 'conduit.connect') { $certificate = idx($params, 'certificate'); if ($certificate) { $token = time(); $params['authToken'] = $token; $params['authSignature'] = sha1($token . $certificate); } unset($params['certificate']); } if ($meta) { $params['__conduit__'] = $meta; } $port = null; if ($this->port) { $port = ':' . $this->port; } $uri = $this->protocol . '://' . $this->host . $port . '/' . $this->path . $method; $data = array('params' => json_encode($params), 'output' => 'json'); if ($this->protocol == 'https') { $core_future = new HTTPSFuture($uri, $data); } else { $core_future = new HTTPFuture($uri, $data); } $core_future->setMethod('POST'); $core_future->setTimeout($this->timeout); $profiler = PhutilServiceProfiler::getInstance(); $this->profilerCallID = $profiler->beginServiceCall(array('type' => 'conduit', 'method' => $method)); $conduit_future = new ConduitFuture($core_future); $conduit_future->setClient($this, $method); $conduit_future->isReady(); return $conduit_future; }
protected function resolveCall(ConduitFuture $method, $timeout = null) { try { return $method->resolve($timeout); } catch (ConduitClientException $ex) { if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { echo phutil_console_wrap("This feature requires a newer version of Phabricator. Please " . "update it using these instructions: " . "http://www.phabricator.com/docs/phabricator/article/" . "Installation_Guide.html#updating-phabricator\n\n"); } throw $ex; } }
public function callMethod($method, array $params) { $meta = array(); if ($this->sessionKey) { $meta['sessionKey'] = $this->sessionKey; } if ($this->connectionID) { $meta['connectionID'] = $this->connectionID; } if ($method == 'conduit.connect') { $certificate = idx($params, 'certificate'); if ($certificate) { $token = time(); $params['authToken'] = $token; $params['authSignature'] = sha1($token . $certificate); } unset($params['certificate']); } if ($meta) { $params['__conduit__'] = $meta; } $port = null; if ($this->port) { $port = ':' . $this->port; } $uri = $this->protocol . '://' . $this->host . $port . '/' . $this->path . $method; $data = array('params' => json_encode($params), 'output' => 'json', '__conduit__' => true); // NOTE: If we're on Windows, the socket-based HTTPFuture won't work // properly. In theory it may be fixable, but the easier fix is just to use // the cURL-based HTTPSFuture for HTTP. We'll lose the ability to // parallelize requests but things will work correctly. $use_https_future = $this->protocol == 'https' || phutil_is_windows(); if ($use_https_future) { $core_future = new HTTPSFuture($uri, $data); } else { $core_future = new HTTPFuture($uri, $data); } $core_future->setMethod('POST'); $core_future->setTimeout($this->timeout); $profiler = PhutilServiceProfiler::getInstance(); $this->profilerCallID = $profiler->beginServiceCall(array('type' => 'conduit', 'method' => $method, 'size' => strlen(http_build_query($data, '', '&')))); $conduit_future = new ConduitFuture($core_future); $conduit_future->setClient($this, $method); $conduit_future->isReady(); return $conduit_future; }
protected final function resolveCall(ConduitFuture $method, $timeout = null) { try { return $method->resolve($timeout); } catch (ConduitClientException $ex) { if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { echo phutil_console_wrap("%s\n\n", pht('This feature requires a newer version of Phabricator. Please ' . 'update it using these instructions: %s', 'https://secure.phabricator.com/book/phabricator/article/' . 'upgrading/')); } throw $ex; } }