3
final class ConduitFuture extends FutureProxy {
6
protected $conduitMethod;
7
private $profilerCallID;
9
public function setClient(ConduitClient $client, $method) {
10
$this->client = $client;
11
$this->conduitMethod = $method;
15
public function beginProfile($data) {
16
$profiler = PhutilServiceProfiler::getInstance();
17
$this->profilerCallID = $profiler->beginServiceCall(
20
'method' => $this->conduitMethod,
21
'size' => strlen(http_build_query($data, '', '&')),
26
protected function didReceiveResult($result) {
27
if ($this->profilerCallID !== null) {
28
$profiler = PhutilServiceProfiler::getInstance();
29
$profiler->endServiceCall(
30
$this->profilerCallID,
34
list($status, $body, $headers) = $result;
35
if ($status->isError()) {
42
if (!strncmp($raw, $shield, strlen($shield))) {
43
$raw = substr($raw, strlen($shield));
46
$data = json_decode($raw, true);
47
if (!is_array($data)) {
49
"Host returned HTTP/200, but invalid JSON data in response to ".
50
"a Conduit method call:\n{$raw}");
53
if ($data['error_code']) {
54
throw new ConduitClientException(
59
$result = $data['result'];
61
$result = $this->client->didReceiveResponse(