Changeset View
Changeset View
Standalone View
Standalone View
src/future/http/HTTPSFuture.php
| Show First 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | public function isReady() { | ||||
| // See T13396. For now, use the streaming response parser only if we're | // See T13396. For now, use the streaming response parser only if we're | ||||
| // downloading the response to disk. | // downloading the response to disk. | ||||
| $use_streaming_parser = (bool)$is_download; | $use_streaming_parser = (bool)$is_download; | ||||
| if (!$this->handle) { | if (!$this->handle) { | ||||
| $uri_object = new PhutilURI($uri); | $uri_object = new PhutilURI($uri); | ||||
| $proxy = PhutilHTTPEngineExtension::buildHTTPProxyURI($uri_object); | $proxy = PhutilHTTPEngineExtension::buildHTTPProxyURI($uri_object); | ||||
| $profiler = PhutilServiceProfiler::getInstance(); | // TODO: Currently, the "proxy" is not passed to the ServiceProfiler | ||||
| $this->profilerCallID = $profiler->beginServiceCall( | // because of changes to how ServiceProfiler is integrated. It would | ||||
| array( | // be nice to pass it again. | ||||
| 'type' => 'http', | |||||
| 'uri' => $uri, | |||||
| 'proxy' => (string)$proxy, | |||||
| )); | |||||
| if (!self::$multi) { | if (!self::$multi) { | ||||
| self::$multi = curl_multi_init(); | self::$multi = curl_multi_init(); | ||||
| if (!self::$multi) { | if (!self::$multi) { | ||||
| throw new Exception(pht('%s failed!', 'curl_multi_init()')); | throw new Exception(pht('%s failed!', 'curl_multi_init()')); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | if ($sink) { | ||||
| $status = head($this->getResult()); | $status = head($this->getResult()); | ||||
| if ($status->isError()) { | if ($status->isError()) { | ||||
| $sink->didFailWork(); | $sink->didFailWork(); | ||||
| } else { | } else { | ||||
| $sink->didCompleteWork(); | $sink->didCompleteWork(); | ||||
| } | } | ||||
| } | } | ||||
| $profiler = PhutilServiceProfiler::getInstance(); | |||||
| $profiler->endServiceCall($this->profilerCallID, array()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| /** | /** | ||||
| * Callback invoked by cURL as it reads HTTP data from the response. We save | * Callback invoked by cURL as it reads HTTP data from the response. We save | ||||
| * the data to a buffer. | * the data to a buffer. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | private function shouldReuseHandles() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| private function isDownload() { | private function isDownload() { | ||||
| return ($this->downloadPath !== null); | return ($this->downloadPath !== null); | ||||
| } | } | ||||
| protected function getServiceProfilerStartParameters() { | |||||
| return array( | |||||
| 'type' => 'http', | |||||
| 'uri' => phutil_string_cast($this->getURI()), | |||||
| ); | |||||
| } | |||||
| } | } | ||||