Changeset View
Changeset View
Standalone View
Standalone View
src/future/http/HTTPFuture.php
| Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | $socket = @stream_socket_client( | ||||
| 'tcp://'.$this->host.':'.$this->port, | 'tcp://'.$this->host.':'.$this->port, | ||||
| $errno, | $errno, | ||||
| $errstr, | $errstr, | ||||
| $ignored_connection_timeout = 1.0, | $ignored_connection_timeout = 1.0, | ||||
| STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT); | STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT); | ||||
| if (!$socket) { | if (!$socket) { | ||||
| $this->stateReady = true; | $this->stateReady = true; | ||||
| $this->result = $this->buildErrorResult( | $this->setResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_CONNECTION_FAILED); | $this->buildErrorResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_CONNECTION_FAILED)); | |||||
| return null; | return null; | ||||
| } | } | ||||
| $ok = stream_set_blocking($socket, 0); | $ok = stream_set_blocking($socket, 0); | ||||
| if (!$ok) { | if (!$ok) { | ||||
| throw new Exception(pht('Failed to set stream nonblocking.')); | throw new Exception(pht('Failed to set stream nonblocking.')); | ||||
| } | } | ||||
| Show All 11 Lines | private function checkSocket() { | ||||
| if (!feof($this->socket) && !$timeout) { | if (!feof($this->socket) && !$timeout) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| $this->stateReady = true; | $this->stateReady = true; | ||||
| if ($timeout) { | if ($timeout) { | ||||
| $this->result = $this->buildErrorResult( | $this->setResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_TIMEOUT); | $this->buildErrorResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_TIMEOUT)); | |||||
| } else if (!$this->stateConnected) { | } else if (!$this->stateConnected) { | ||||
| $this->result = $this->buildErrorResult( | $this->setResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_CONNECTION_REFUSED); | $this->buildErrorResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_CONNECTION_REFUSED)); | |||||
| } else if (!$this->stateWriteComplete) { | } else if (!$this->stateWriteComplete) { | ||||
| $this->result = $this->buildErrorResult( | $this->setResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_CONNECTION_FAILED); | $this->buildErrorResult( | ||||
| HTTPFutureTransportResponseStatus::ERROR_CONNECTION_FAILED)); | |||||
| } else { | } else { | ||||
| $this->result = $this->parseRawHTTPResponse($this->response); | $this->setResult($this->parseRawHTTPResponse($this->response)); | ||||
| } | } | ||||
| $profiler = PhutilServiceProfiler::getInstance(); | $profiler = PhutilServiceProfiler::getInstance(); | ||||
| $profiler->endServiceCall($this->profilerCallID, array()); | $profiler->endServiceCall($this->profilerCallID, array()); | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines | |||||