Exemplo n.º 1
0
 /**
  * Find value of the first header with given name.
  *
  * @param list List of headers from `resolve()`.
  * @param string Case insensitive header name.
  * @return string Value of the header or null if not found.
  * @task resolve
  */
 public static function getHeader(array $headers, $search)
 {
     Utils::assert_instances_of($headers, 'array');
     foreach ($headers as $header) {
         list($name, $value) = $header;
         if (strcasecmp($name, $search) == 0) {
             return $value;
         }
     }
     return null;
 }
 protected function getErrorCodeDescription($code)
 {
     $map = array(self::ERROR_TIMEOUT => 'The request took too long to complete.', self::ERROR_CONNECTION_ABORTED => 'The remote host closed the connection before the request completed.', self::ERROR_CONNECTION_REFUSED => 'The remote host refused the connection. This usually means the ' . 'host is not running an HTTP server, or the network is blocking ' . 'connections from this machine. Verify you can connect to the ' . 'remote host from this host.', self::ERROR_CONNECTION_FAILED => 'Connection could not be initiated. This usually indicates a DNS ' . 'problem: verify the domain name is correct, that you can ' . 'perform a DNS lookup for it from this machine. (Did you add the ' . 'domain to `/etc/hosts` on some other machine, but not this one?) ' . 'This might also indicate that you specified the wrong port.');
     return Utils::idx($map, $code);
 }
Exemplo n.º 3
0
 /**
  * Close and free resources if necessary.
  *
  * @return void
  * @task internal
  */
 private function closeProcess()
 {
     foreach ($this->pipes as $pipe) {
         if (isset($pipe)) {
             @fclose($pipe);
         }
     }
     $this->pipes = array(null, null, null);
     if ($this->proc) {
         @proc_close($this->proc);
         $this->proc = null;
     }
     $this->stdin = null;
     if ($this->profilerCallID !== null) {
         $profiler = ServiceProfiler\PhutilServiceProfiler::getInstance();
         $profiler->endServiceCall($this->profilerCallID, array('err' => $this->result ? Utils\Utils::idx($this->result, 0) : null));
         $this->profilerCallID = null;
     }
 }
 protected function getErrorCodeDescription($code)
 {
     static $map = array(404 => 'Not Found', 500 => 'Internal Server Error');
     return \Hazbo\Component\Utils\Utils::idx($map, $code) . "\n" . $this->excerpt . "\n";
 }