Zend_Http_Client_Exception example

public function setUri($uri)
    {
        if ($uri instanceof Zend_Uri_Http) {
            // clone the URI in order to keep the passed parameter constant             $uri = clone $uri;
        } elseif (is_string($uri)) {
            $uri = Zend_Uri::factory($uri);
        }

        if (!$uri instanceof Zend_Uri_Http) {
            /** @see Zend_Http_Client_Exception */
            throw new Zend_Http_Client_Exception('Passed parameter is not a valid HTTP URI.');
        }

        // Set auth if username and password has been specified in the uri         if ($uri->getUsername() && $uri->getPassword()) {
            $this->setAuth($uri->getUsername()$uri->getPassword());
        }

        // We have no ports, set the defaults         if ($uri->getPort()) {
            $uri->setPort(($uri->getScheme() == 'https' ? 443 : 80));
        }

        
            curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
        } elseif ($method == Zend_Http_Client::DELETE) {
            // This is a DELETE by a setRawData string             curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
        }

        // set additional curl options         if (isset($this->_config['curloptions'])) {
            foreach ((array)$this->_config['curloptions'] as $k => $v) {
                if (!in_array($k$this->_invalidOverwritableCurlOptions)) {
                    if (curl_setopt($this->_curl, $k$v) == false) {
                        throw new Zend_Http_Client_Exception(sprintf("Unknown or erroreous cURL option '%s' set", $k));
                    }
                }
            }
        }

        // send the request         $response = curl_exec($this->_curl);

        // if we used streaming, headers are already there         if(!is_resource($this->out_stream)) {
            $this->_response = $response;
        }
Home | Imprint | This part of the site doesn't use cookies.