当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Uri_Http::getPort方法代码示例

本文整理汇总了PHP中Zend_Uri_Http::getPort方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Uri_Http::getPort方法的具体用法?PHP Zend_Uri_Http::getPort怎么用?PHP Zend_Uri_Http::getPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Uri_Http的用法示例。


在下文中一共展示了Zend_Uri_Http::getPort方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare_headers

 /**
  * Prepare the request headers
  *
  * @return array
  */
 protected function prepare_headers()
 {
     $headers = array();
     // Set the host header
     if (!isset($this->headers['host'])) {
         $host = $this->uri->getHost();
         // If the port is not default, add it
         if (!($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80 || $this->uri->getScheme() == 'https' && $this->uri->getPort() == 443)) {
             $host .= ':' . $this->uri->getPort();
         }
         //            var_dump($host);
         $headers[] = "Host: {$host}";
     }
     // Set the connection header
     if (!isset($this->headers['connection'])) {
         if (!$this->config['keepalive']) {
             $headers[] = "Connection: close";
         }
     }
     // Set the Accept-encoding header if not set - depending on whether
     // zlib is available or not.
     if (!isset($this->headers['accept-encoding'])) {
         if (function_exists('gzinflate') && $this->config['adapter'] !== 'Zend_Http_Client_Adapter_CurlProxy') {
             $headers[] = 'Accept-encoding: gzip, deflate';
         } else {
             $headers[] = 'Accept-encoding: identity';
         }
     }
     // Set the content-type header
     if ($this->method == self::POST && (!isset($this->headers['content-type']) && isset($this->enctype))) {
         $headers[] = "Content-type: {$this->enctype}";
     }
     // Set the user agent header
     if (!isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
         $headers[] = "User-agent: {$this->config['useragent']}";
     }
     // Set HTTP authentication if needed
     if (is_array($this->auth)) {
         $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']);
         $headers[] = "Authorization: {$auth}";
     }
     // Load cookies from cookie jar
     if (isset($this->cookiejar)) {
         $cookstr = $this->cookiejar->getMatchingCookies($this->uri, true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
         if ($cookstr) {
             $headers[] = "Cookie: {$cookstr}";
         }
     }
     // Add all other user defined headers
     foreach ($this->headers as $header) {
         list($name, $value) = $header;
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         $headers[] = "{$name}: {$value}";
     }
     return $headers;
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:63,代码来源:Client.php

示例2: write

 /**
  * Send request to the proxy server with streaming support
  *
  * @param string        $method
  * @param Zend_Uri_Http $uri
  * @param string        $http_ver
  * @param array         $headers
  * @param string        $body
  * @return string Request as string
  */
 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
 {
     // If no proxy is set, throw an error
     if (!$this->config['proxy_host']) {
         // require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception('No proxy host set!');
     }
     // Make sure we're properly connected
     if (!$this->socket) {
         // require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception('Trying to write but we are not connected');
     }
     $host = $this->config['proxy_host'];
     $port = $this->config['proxy_port'];
     if ($this->connected_to[0] != $host || $this->connected_to[1] != $port) {
         // require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception('Trying to write but we are connected to the wrong proxy ' . 'server');
     }
     // Add Proxy-Authorization header
     if ($this->config['proxy_user'] && !isset($headers['proxy-authorization'])) {
         $headers['proxy-authorization'] = Zend_Http_Client::encodeAuthHeader($this->config['proxy_user'], $this->config['proxy_pass'], $this->config['proxy_auth']);
     }
     // if we are proxying HTTPS, preform CONNECT handshake with the proxy
     if ($uri->getScheme() == 'https' && !$this->negotiated) {
         $this->connectHandshake($uri->getHost(), $uri->getPort(), $http_ver, $headers);
         $this->negotiated = true;
     }
     // Save request method for later
     $this->method = $method;
     // Build request headers
     $request = "{$method} {$uri->__toString()} HTTP/{$http_ver}\r\n";
     // Add all headers to the request string
     foreach ($headers as $k => $v) {
         if (is_string($k)) {
             $v = "{$k}: {$v}";
         }
         $request .= "{$v}\r\n";
     }
     $request .= "\r\n";
     // Send the request headers
     if (!@fwrite($this->socket, $request)) {
         // require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception('Error writing request to proxy server');
     }
     // Read from $body, write to socket
     $chunk = $body->read(self::CHUNK_SIZE);
     while ($chunk !== false) {
         if (!@fwrite($this->socket, $chunk)) {
             // require_once 'Zend/Http/Client/Adapter/Exception.php';
             throw new Zend_Http_Client_Adapter_Exception('Error writing request to server');
         }
         $chunk = $body->read(self::CHUNK_SIZE);
     }
     $body->closeFileHandle();
     return 'Large upload, request is not cached.';
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:66,代码来源:HttpAdapterStreamingProxy.php

示例3: write

    /**
     * Send request to the remote server with streaming support.
     *
     * @param string        $method
     * @param Zend_Uri_Http $uri
     * @param string        $http_ver
     * @param array         $headers
     * @param string        $body
     * @return string Request as string
     */
    public function write($method, $uri, $http_ver = '1.1', $headers = array(),
        $body = '')
    {
        // Make sure we're properly connected
        if (! $this->socket) {
            require_once 'Zend/Http/Client/Adapter/Exception.php';
            throw new Zend_Http_Client_Adapter_Exception(
                'Trying to write but we are not connected');
        }

        $host = $uri->getHost();
        $host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
        if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
            require_once 'Zend/Http/Client/Adapter/Exception.php';
            throw new Zend_Http_Client_Adapter_Exception(
                'Trying to write but we are connected to the wrong host');
        }

        // Save request method for later
        $this->method = $method;

        // Build request headers
        $path = $uri->getPath();
        if ($uri->getQuery()) $path .= '?' . $uri->getQuery();
        $request = "{$method} {$path} HTTP/{$http_ver}\r\n";
        foreach ($headers as $k => $v) {
            if (is_string($k)) $v = ucfirst($k) . ": $v";
            $request .= "$v\r\n";
        }

        // Send the headers over
        $request .= "\r\n";
        if (! @fwrite($this->socket, $request)) {
            require_once 'Zend/Http/Client/Adapter/Exception.php';
            throw new Zend_Http_Client_Adapter_Exception(
                'Error writing request to server');
        }


        //read from $body, write to socket
        $chunk = $body->read(self::CHUNK_SIZE);
        while ($chunk !== FALSE) {
            if (! @fwrite($this->socket, $chunk)) {
                require_once 'Zend/Http/Client/Adapter/Exception.php';
                throw new Zend_Http_Client_Adapter_Exception(
                    'Error writing request to server');
            }
            $chunk = $body->read(self::CHUNK_SIZE);
        }
        $body->closeFileHandle();
        return 'Large upload, request is not cached.';
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:62,代码来源:HttpAdapterStreamingSocket.php

示例4: prepare_headers

 /**
  * Prepare the request headers
  * 
  * @return array
  */
 protected function prepare_headers()
 {
     $headers = array();
     // Set the host header
     if (!isset($this->headers['host'])) {
         $host = $this->uri->getHost();
         // If the port is not default, add it
         if (!($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80 || $this->uri->getScheme() == 'https' && $this->uri->getPort() == 443)) {
             $host .= ':' . $this->uri->getPort();
         }
         $headers[] = "Host: {$host}";
     }
     // Set the connection header
     if (!isset($this->headers['connection'])) {
         if (!$this->config['keepalive']) {
             $headers[] = "Connection: close";
         }
     }
     // Set the content-type header
     if (!isset($this->headers['content-type']) && isset($this->enctype)) {
         $headers[] = "Content-type: {$this->enctype}";
     }
     // Set the user agent header
     if (!isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
         $headers[] = "User-agent: {$this->config['useragent']}";
     }
     // Set HTTP authentication if needed
     if (is_array($this->auth)) {
         $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']);
         $headers[] = "Authorization: {$auth}";
     }
     // Load cookies from cookie jar
     if (isset($this->cookiejar)) {
         $cookstr = $this->cookiejar->getMatchingCookies($this->uri, true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
         if ($cookstr) {
             $headers[] = "Cookie: {$cookstr}";
         }
     }
     // Add all other user defined headers
     foreach ($this->headers as $name => $value) {
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         $headers[] = ucfirst($name) . ": {$value}";
     }
     return $headers;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:52,代码来源:Client.php

示例5: write

 /**
  * Send request to the remote server
  *
  * @param  string        $method
  * @param  Zend_Uri_Http $uri
  * @param  float         $http_ver
  * @param  array         $headers
  * @param  string        $body
  * @return string        $request
  * @throws Zend_Http_Client_Adapter_Exception If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option
  */
 public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $body = '')
 {
     // Make sure we're properly connected
     if (!$this->_curl) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
     }
     if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
     }
     // set URL
     curl_setopt($this->_curl, CURLOPT_URL, $uri->__toString());
     // ensure correct curl call
     $curlValue = true;
     switch ($method) {
         case Zend_Http_Client::GET:
             $curlMethod = CURLOPT_HTTPGET;
             break;
         case Zend_Http_Client::POST:
             $curlMethod = CURLOPT_POST;
             break;
         case Zend_Http_Client::PUT:
             // There are two different types of PUT request, either a Raw Data string has been set
             // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used.
             if (is_resource($body)) {
                 $this->_config['curloptions'][CURLOPT_INFILE] = $body;
             }
             if (isset($this->_config['curloptions'][CURLOPT_INFILE])) {
                 // Now we will probably already have Content-Length set, so that we have to delete it
                 // from $headers at this point:
                 foreach ($headers as $k => $header) {
                     if (preg_match('/Content-Length:\\s*(\\d+)/i', $header, $m)) {
                         if (is_resource($body)) {
                             $this->_config['curloptions'][CURLOPT_INFILESIZE] = (int) $m[1];
                         }
                         unset($headers[$k]);
                     }
                 }
                 if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) {
                     require_once 'Zend/Http/Client/Adapter/Exception.php';
                     throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
                 }
                 if (is_resource($body)) {
                     $body = '';
                 }
                 $curlMethod = CURLOPT_PUT;
             } else {
                 $curlMethod = CURLOPT_CUSTOMREQUEST;
                 $curlValue = "PUT";
             }
             break;
         case Zend_Http_Client::DELETE:
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "DELETE";
             break;
         case Zend_Http_Client::OPTIONS:
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "OPTIONS";
             break;
         case Zend_Http_Client::TRACE:
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "TRACE";
             break;
         case Zend_Http_Client::HEAD:
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "HEAD";
             break;
         default:
             // For now, through an exception for unsupported request methods
             require_once 'Zend/Http/Client/Adapter/Exception.php';
             throw new Zend_Http_Client_Adapter_Exception("Method currently not supported");
     }
     if (is_resource($body) && $curlMethod != CURLOPT_PUT) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception("Streaming requests are allowed only with PUT");
     }
     // get http version to use
     $curlHttp = $httpVersion == 1.1 ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
     // mark as HTTP request and set HTTP method
     curl_setopt($this->_curl, $curlHttp, true);
     curl_setopt($this->_curl, $curlMethod, $curlValue);
     if ($this->out_stream) {
         // headers will be read into the response
         curl_setopt($this->_curl, CURLOPT_HEADER, false);
         curl_setopt($this->_curl, CURLOPT_HEADERFUNCTION, array($this, "readHeader"));
         // and data will be written into the file
         curl_setopt($this->_curl, CURLOPT_FILE, $this->out_stream);
     } else {
//.........这里部分代码省略.........
开发者ID:aguerojahannes,项目名称:aguerojahannes.com,代码行数:101,代码来源:Curl.php

示例6: write

 /**
  * Send request to the remote server
  *
  * @param string        $method
  * @param Zend_Uri_Http $uri
  * @param string        $http_ver
  * @param array         $headers
  * @param string        $body
  * @return string Request as string
  */
 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
 {
     // Make sure we're properly connected
     if (!$this->socket) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception('Trying to write but we are not connected');
     }
     $host = $uri->getHost();
     $host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
     if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception('Trying to write but we are connected to the wrong host');
     }
     // Save request method for later
     $this->method = $method;
     // Build request headers
     $path = $uri->getPath();
     if ($uri->getQuery()) {
         $path .= '?' . $uri->getQuery();
     }
     $request = "{$method} {$path} HTTP/{$http_ver}\r\n";
     foreach ($headers as $k => $v) {
         if (is_string($k)) {
             $v = ucfirst($k) . ": {$v}";
         }
         $request .= "{$v}\r\n";
     }
     // Add the request body
     $request .= "\r\n" . $body;
     // Send the request
     if (!@fwrite($this->socket, $request)) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception('Error writing request to server');
     }
     return $request;
 }
开发者ID:DBezemer,项目名称:server,代码行数:46,代码来源:Socket.php

示例7: write

 /**
  * Send request to the remote server
  *
  * @param string $method
  * @param Zend_Uri_Http $uri
  * @param float $http_ver
  * @param array  $headers
  * @param string $body
  */
 public function write($method, $uri, $http_ver = 1.1, $headers = array(), $body = '')
 {
     // Make sure we're properly connected
     if (!$this->socket) {
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
     }
     $host = $uri->getHost();
     $host = strtolower($uri->getScheme()) == 'https' ? 'ssl://' . $host : $host;
     if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
     }
     // Build request headers
     $request = "{$method} {$uri->__toString()} HTTP/{$http_ver}\r\n";
     foreach ($headers as $k => $v) {
         if (is_string($k)) {
             $v = ucfirst($k) . ": {$v}";
         }
         $request .= "{$v}\r\n";
     }
     // Add the request body
     $request .= "\r\n" . $body;
     // Send the request
     fwrite($this->socket, $request);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:33,代码来源:Socket.php

示例8: write

 /**
  * Send request to the remote server
  *
  * @param string        $method
  * @param Zend_Uri_Http $uri
  * @param float         $http_ver
  * @param array         $headers
  * @param string        $body
  */
 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
 {
     // set URL
     curl_setopt($this->curl, CURLOPT_URL, $uri->__toString());
     // Make sure we're properly connected
     if (!$this->curl) {
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
     }
     if ($this->connected_to[0] != $uri->getHost() || $this->connected_to[1] != $uri->getPort()) {
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
     }
     // ensure correct curl call
     if ($method == Zend_Http_Client::GET) {
         $curlMethod = CURLOPT_HTTPGET;
     } elseif ($method == Zend_Http_Client::POST) {
         $curlMethod = CURLOPT_POST;
     } else {
         // TODO: use CURLOPT_PUT for PUT requests, CURLOPT_CUSTOMREQUEST for other types of calls
         // For now, through an exception for unsupported request methods
         throw new Zend_Http_Client_Adapter_Exception("Method currently not supported");
     }
     // get http version to use
     $curlHttp = ($http_ver = 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
     curl_setopt($this->curl, $curlMethod, true);
     curl_setopt($this->curl, $curlHttp, true);
     // ensure headers are also returned
     curl_setopt($this->curl, CURLOPT_HEADER, true);
     // ensure actual response is returned
     curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
     // set additional headers
     curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
     if ($method == Zend_Http_Client::POST) {
         curl_setopt($this->curl, CURLOPT_POSTFIELDS, $body);
     }
     // send the request
     $this->response = curl_exec($this->curl);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:46,代码来源:Curl.php

示例9: write

 /**
  * Send request to the remote server
  *
  * @param  string        $method
  * @param  Zend_Uri_Http $uri
  * @param  float         $http_ver
  * @param  array         $headers
  * @param  string        $body
  * @return string        $request
  * @throws Zend_Http_Client_Adapter_Exception If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option
  */
 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
 {
     // Make sure we're properly connected
     if (!$this->_curl) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are not connected");
     }
     if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) {
         require_once 'Zend/Http/Client/Adapter/Exception.php';
         throw new Zend_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
     }
     // set URL
     curl_setopt($this->_curl, CURLOPT_URL, $uri->__toString());
     // ensure correct curl call
     $curlValue = true;
     switch ($method) {
         case Zend_Http_Client::GET:
             $curlMethod = CURLOPT_HTTPGET;
             break;
         case Zend_Http_Client::POST:
             $curlMethod = CURLOPT_POST;
             break;
         case Zend_Http_Client::PUT:
             // There are two different types of PUT request, either a Raw Data string has been set
             // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used.
             if (isset($this->_config['curloptions'][CURLOPT_INFILE])) {
                 if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) {
                     require_once 'Zend/Http/Client/Adapter/Exception.php';
                     throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
                 }
                 // Now we will probably already have Content-Length set, so that we have to delete it
                 // from $headers at this point:
                 foreach ($headers as $k => $header) {
                     if (stristr($header, "Content-Length:") !== false) {
                         unset($headers[$k]);
                     }
                 }
                 $curlMethod = CURLOPT_PUT;
             } else {
                 $curlMethod = CURLOPT_CUSTOMREQUEST;
                 $curlValue = "PUT";
             }
             break;
         case Zend_Http_Client::DELETE:
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "DELETE";
             break;
         case Zend_Http_Client::OPTIONS:
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "OPTIONS";
             break;
         case Zend_Http_Client::TRACE:
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = "TRACE";
             break;
         default:
             // For now, through an exception for unsupported request methods
             require_once 'Zend/Http/Client/Adapter/Exception.php';
             throw new Zend_Http_Client_Adapter_Exception("Method currently not supported");
     }
     // get http version to use
     $curlHttp = ($http_ver = 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
     // mark as HTTP request and set HTTP method
     curl_setopt($this->_curl, $curlHttp, true);
     curl_setopt($this->_curl, $curlMethod, $curlValue);
     // ensure headers are also returned
     curl_setopt($this->_curl, CURLOPT_HEADER, true);
     // ensure actual response is returned
     curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
     // set additional headers
     $headers['Accept'] = '';
     curl_setopt($this->_curl, CURLOPT_HTTPHEADER, $headers);
     /**
      * Make sure POSTFIELDS is set after $curlMethod is set:
      * @link http://de2.php.net/manual/en/function.curl-setopt.php#81161
      */
     if ($method == Zend_Http_Client::POST) {
         curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
     } elseif ($curlMethod == CURLOPT_PUT) {
         // this covers a PUT by file-handle:
         // Make the setting of this options explicit (rather than setting it through the loop following a bit lower)
         // to group common functionality together.
         curl_setopt($this->_curl, CURLOPT_INFILE, $this->_config['curloptions'][CURLOPT_INFILE]);
         curl_setopt($this->_curl, CURLOPT_INFILESIZE, $this->_config['curloptions'][CURLOPT_INFILESIZE]);
         unset($this->_config['curloptions'][CURLOPT_INFILE]);
         unset($this->_config['curloptions'][CURLOPT_INFILESIZE]);
     } elseif ($method == Zend_Http_Client::PUT) {
         // This is a PUT by a setRawData string, not by file-handle
         curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:silverstripe-external-content,代码行数:101,代码来源:Curl.php

示例10: prepare_headers

 /**
  * Prepare the request headers
  * 
  * @return array
  */
 protected function prepare_headers()
 {
     $headers = array();
     // Set the host header
     if (!isset($this->headers['host'])) {
         $host = $this->uri->getHost() . ($this->uri->getPort() == 80 ? '' : ':' . $this->uri->getPort());
         $headers[] = "Host: {$host}";
     }
     // Set the connection header
     // For now, only support closed connections
     if (!isset($this->headers['connection'])) {
         $headers[] = "Connection: close";
     }
     // Set the content-type header
     if (!isset($this->headers['content-type']) && isset($this->enctype)) {
         $headers[] = "Content-type: {$this->enctype}";
     }
     // Set the user agent header
     if (!isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
         $headers[] = "User-agent: {$this->config['useragent']}";
     }
     // Set HTTP authentication if needed
     if (is_array($this->auth)) {
         $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']);
         $headers[] = "Authorization: {$auth}";
     }
     // Load cookies from cookie jar
     if (isset($this->Cookiejar)) {
         $cookstr = $this->Cookiejar->getMatchingCookies($this->uri, true, Zend_Http_Cookiejar::COOKIE_STRING_CONCAT);
         if ($cookstr) {
             $headers[] = "Cookie: {$cookstr}";
         }
     }
     // Add all other user defined headers
     foreach ($this->headers as $name => $value) {
         if (is_array($value)) {
             foreach ($value as $subval) {
                 $headers[] = ucfirst($name) . ": {$subval}";
             }
         } else {
             $headers[] = ucfirst($name) . ": {$value}";
         }
     }
     return $headers;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:50,代码来源:Client.php

示例11: normalizeUri

 /**
  * Normalizes the uri for internal usage.
  *
  * @param Zend_Uri_Http $uri
  * @return Zend_Uri_Http
  */
 protected function normalizeUri(Zend_Uri_Http $uri)
 {
     $defaultPorts = array('http' => 80, 'https' => 443);
     foreach ($defaultPorts as $scheme => $port) {
         if ($uri->getScheme() === $scheme && $uri->getPort() == $port) {
             // Remove default port. Do not modify original object.
             $uri = clone $uri;
             $uri->setPort('');
             return $uri;
         }
     }
     return $uri;
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:19,代码来源:Adapter.php


注:本文中的Zend_Uri_Http::getPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。