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


PHP Zend_Uri_Http类代码示例

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


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

示例1: 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

示例2: write

 /**
  * Send request to the remote server
  *
  * @param string        $method   Method
  * @param Zend_Uri_Http $uri      Uri
  * @param string        $http_ver HTTP version
  * @param array         $headers  Headers
  * @param string        $body     Body
  *
  * @return string Request as string
  */
 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
 {
     $request = false;
     if (Mage::app()->useCache(self::CACHE_TYPE)) {
         $this->_params = $uri->getQueryAsArray();
         try {
             $request = parent::write($method, $uri, $http_ver, $headers, $body);
         } catch (Zend_Http_Client_Adapter_Exception $e) {
             Mage::log("{$this->_code} [socket]: {$e->getMessage()}");
         }
     } else {
         $request = parent::write($method, $uri, $http_ver, $headers, $body);
     }
     return $request;
 }
开发者ID:reginaldojunior,项目名称:correios-1,代码行数:26,代码来源:Socket.php

示例3: isValid

    /**
     * Defined by Zend_Validate_Interface
     *
     * Returns true if and only if the $value is a valid url that starts with http(s)://
     * and the hostname is a valid TLD
     *
     * @param  string $value
     * @throws Zend_Validate_Exception if a fatal error occurs for validation process
     * @return boolean
     */
    public function isValid($value)
    {
        if (!is_string($value)) {
            $this->_error(self::INVALID_URL);
             return false;
        }
		
        $this->_setValue($value);
        //get a Zend_Uri_Http object for our URL, this will only accept http(s) schemes
        try {
            $uriHttp = Zend_Uri_Http::fromString($value);
        } catch (Zend_Uri_Exception $e) {
            $this->_error(self::INVALID_URL);
            return false;
        }
        
        //if we have a valid URI then we check the hostname for valid TLDs, and not local urls
        $hostnameValidator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS); //do not allow local hostnames, this is the default

        if (!$hostnameValidator->isValid($uriHttp->getHost())) {
            $this->_error(self::INVALID_URL);
            return false;
        }
        return true;
    }
开发者ID:rondobley,项目名称:Zend-Framework-Validate-URL,代码行数:35,代码来源:IsUrl.php

示例4: getUrl

 /**
  * Generate a redirect URL from the allowable parameters and configured
  * values.
  *
  * @return string
  */
 public function getUrl()
 {
     $params = $this->assembleParams();
     $uri = Zend_Uri_Http::fromString($this->_consumer->getUserAuthorizationUrl());
     $uri->setQuery($this->_httpUtility->toEncodedQueryString($params));
     return $uri->getUri();
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:13,代码来源:UserAuthorization.php

示例5: _getWechatOAuthUrl

 private function _getWechatOAuthUrl($appid, $scope, $callbackurl, $state)
 {
     $client = Zend_Uri_Http::fromString("https://open.weixin.qq.com/connect/oauth2/authorize");
     $client->addReplaceQueryParameters(array("appid" => $appid, "redirect_uri" => $callbackurl, "response_type" => "code", "scope" => $scope, "sate" => $state));
     $client->setFragment("wechat_redirect");
     return $client->getUri();
 }
开发者ID:patrickouc,项目名称:fwm-wechatsso,代码行数:7,代码来源:IndexController.php

示例6: _processRequest

 /**
  * Process oauth related protocol information and return as an array
  *
  * @param string $authHeaderValue
  * @param string $contentTypeHeader
  * @param string $requestBodyString
  * @param string $requestUrl
  * @return array
  * merged array of oauth protocols and request parameters. eg :
  * <pre>
  * array (
  *         'oauth_version' => '1.0',
  *         'oauth_signature_method' => 'HMAC-SHA1',
  *         'oauth_nonce' => 'rI7PSWxTZRHWU3R',
  *         'oauth_timestamp' => '1377183099',
  *         'oauth_consumer_key' => 'a6aa81cc3e65e2960a4879392445e718',
  *         'oauth_signature' => 'VNg4mhFlXk7%2FvsxMqqUd5DWIj9s%3D'
  * )
  * </pre>
  */
 protected function _processRequest($authHeaderValue, $contentTypeHeader, $requestBodyString, $requestUrl)
 {
     $protocolParams = [];
     if (!$this->_processHeader($authHeaderValue, $protocolParams)) {
         return [];
     }
     if ($contentTypeHeader && 0 === strpos($contentTypeHeader, \Zend_Http_Client::ENC_URLENCODED)) {
         $protocolParamsNotSet = !$protocolParams;
         parse_str($requestBodyString, $protocolBodyParams);
         foreach ($protocolBodyParams as $bodyParamName => $bodyParamValue) {
             if (!$this->_isProtocolParameter($bodyParamName)) {
                 $protocolParams[$bodyParamName] = $bodyParamValue;
             } elseif ($protocolParamsNotSet) {
                 $protocolParams[$bodyParamName] = $bodyParamValue;
             }
         }
     }
     $protocolParamsNotSet = !$protocolParams;
     $queryString = \Zend_Uri_Http::fromString($requestUrl)->getQuery();
     $this->_extractQueryStringParams($protocolParams, $queryString);
     if ($protocolParamsNotSet) {
         $this->_fetchProtocolParamsFromQuery($protocolParams, $queryString);
     }
     // Combine request and header parameters
     return $protocolParams;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:46,代码来源:Request.php

示例7: _requireValidSchacHomeOrganization

 protected function _requireValidSchacHomeOrganization($responseAttributes)
 {
     if (!isset($responseAttributes[self::URN_MACE_TERENA_SCHACHOMEORG])) {
         return self::URN_MACE_TERENA_SCHACHOMEORG . " missing in attributes!";
     }
     $schacHomeOrganizationValues = $responseAttributes[self::URN_MACE_TERENA_SCHACHOMEORG];
     if (count($schacHomeOrganizationValues) === 0) {
         return self::URN_MACE_TERENA_SCHACHOMEORG . " has no values";
     }
     if (count($schacHomeOrganizationValues) > 1) {
         return self::URN_MACE_TERENA_SCHACHOMEORG . " has too many values";
     }
     $schacHomeOrganization = $schacHomeOrganizationValues[0];
     $reservedSchacHomeOrganization = $this->_isReservedSchacHomeOrganization($schacHomeOrganization);
     if ($reservedSchacHomeOrganization === TRUE) {
         return self::URN_MACE_TERENA_SCHACHOMEORG . " is reserved for another IdP!";
     }
     $validHostName = false;
     try {
         $uri = Zend_Uri_Http::fromString('http://' . $schacHomeOrganization);
         $validHostName = $uri->validateHost($schacHomeOrganization);
     } catch (Zend_Validate_Exception $e) {
     }
     if (!$validHostName) {
         return self::URN_MACE_TERENA_SCHACHOMEORG . " is not a valid hostname!";
     }
     // Passed all the checks, valid SHO!
     return false;
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:29,代码来源:ValidateRequiredAttributes.php

示例8: testSimpleFromString

    public function testSimpleFromString()
    {
        $uri = 'http://www.zend.com';

        $obj = Zend_Uri_Http::fromString($uri);
        $this->assertEquals($uri, $obj->getUri(), 'getUri() returned value that differs from input');
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:HttpTest.php

示例9: regenerateMediaFiles

 /**
  * Delete content of media/js and media/css folders to refresh with updated compressed/minified js/css content
  * If disabled, the updates are done each time an original file is updated. Can be resource overload on live website.
  * 
  * @param Mage_Core_Model_Observer $observer
  */
 public function regenerateMediaFiles($observer)
 {
     if (Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && (Mage::getStoreConfigFlag('uioptimization/csscompression/enabled') || Mage::getStoreConfigFlag('uioptimization/jscompression/enabled'))) {
         // Clean up media/css and media/js folders and recreate the folders if necessary
         try {
             Mage::getModel('core/design_package')->cleanMergedJsCss();
             Mage::dispatchEvent('clean_media_cache_after');
         } catch (Exception $e) {
             Mage::logException($e);
             return;
         }
         $stores = Mage::app()->getStores();
         foreach ($stores as $id => $v) {
             $url = Zend_Uri_Http::fromString(Mage::app()->getStore($id)->getBaseUrl());
             // Recreate the js and css compressed file by using the normal process
             try {
                 $curl = new Zend_Http_Client_Adapter_Curl();
                 $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
                 $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
                 $curl->connect($url->getHost(), $url->getPort(), Mage_Core_Model_Store::isCurrentlySecure());
                 $curl->write(Zend_Http_Client::GET, $url);
                 $curl->close();
                 Mage::log('[Diglin_UIOptimization_Model_Observer] Update media js/css content for the different stores', ZEND_LOG::DEBUG);
             } catch (Exception $e) {
                 Mage::logException($e);
                 return;
             }
         }
     }
 }
开发者ID:FranchuCorraliza,项目名称:magento,代码行数:36,代码来源:Observer.php

示例10: getEndpoint

 /**
  * Gets the provided endpoint
  * 
  * @return Zend_Uri_Http
  */
 public function getEndpoint()
 {
     if (empty($this->_endpoint)) {
         $this->_endpoint = Zend_Uri_Http::fromString(self::ENDPOINT_URL);
     }
     return $this->_endpoint;
 }
开发者ID:NicholasMiller,项目名称:Zend_Servce_Amazon_Ses,代码行数:12,代码来源:Ses.php

示例11: checkOAuthRequest

 /**
  * Validate OAuth request
  * @param Zend_Uri_Http $url Request URL, will use current if null
  * @param array $params Additional parameters
  * @return bool
  * @throws Zend_Oauth_Exception
  */
 public function checkOAuthRequest(Zend_Uri_Http $url = null, $params = array())
 {
     if (empty($url)) {
         $this->url = $this->getRequestUrl();
     } else {
         $this->url = clone $url;
     }
     // We'll ignore query for the pruposes of URL matching
     $this->url->setQuery('');
     if (isset($_SERVER['REQUEST_METHOD'])) {
         $method = $_SERVER['REQUEST_METHOD'];
     } elseif (isset($_SERVER['HTTP_METHOD'])) {
         $method = $_SERVER['HTTP_METHOD'];
     } else {
         $method = 'GET';
     }
     $params = $this->assembleParams($method, $params);
     $this->checkSignatureMethod($params['oauth_signature_method']);
     $this->checkRequiredParams($params);
     $this->timestamp = $params['oauth_timestamp'];
     $this->nonce = $params['oauth_nonce'];
     $this->consumer_key = $params['oauth_consumer_key'];
     if (!is_callable($this->nonceHandler)) {
         throw new Zend_Oauth_Exception("Nonce handler not callable", self::BAD_NONCE);
     }
     $res = call_user_func($this->nonceHandler, $this);
     if ($res != self::OK) {
         throw new Zend_Oauth_Exception("Invalid request", $res);
     }
     if (!is_callable($this->consumerHandler)) {
         throw new Zend_Oauth_Exception("Consumer handler not callable", self::CONSUMER_KEY_UNKNOWN);
     }
     $res = call_user_func($this->consumerHandler, $this);
     // this will set $this->consumer_secret if OK
     if ($res != self::OK) {
         throw new Zend_Oauth_Exception("Consumer key invalid", $res);
     }
     if ($this->needsToken()) {
         $this->token = $params['oauth_token'];
         $this->verifier = $params['oauth_verifier'];
         if (!is_callable($this->tokenHandler)) {
             throw new Zend_Oauth_Exception("Token handler not callable", self::TOKEN_REJECTED);
         }
         $res = call_user_func($this->tokenHandler, $this);
         // this will set $this->token_secret if OK
         if ($res != self::OK) {
             throw new Zend_Oauth_Exception("Token invalid", $res);
         }
     }
     $util = new Zend_Oauth_Http_Utility();
     $req_sign = $params['oauth_signature'];
     unset($params['oauth_signature']);
     $our_sign = $util->sign($params, $params['oauth_signature_method'], $this->consumer_secret, $this->token_secret, $method, $this->url->getUri());
     if ($req_sign != $our_sign) {
         // TODO: think how to extract signature base string
         $this->problem = $our_sign;
         throw new Zend_Oauth_Exception("Invalid signature", self::INVALID_SIGNATURE);
     }
     return true;
 }
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:67,代码来源:Provider.php

示例12: getUri

 /**
  * Get the URI for the next request
  *
  * @param boolean $as_string If true, will return the URI as a string
  * @return Zend_Uri_Http|string
  */
 public function getUri($as_string = false)
 {
     if ($as_string && $this->uri instanceof Zend_Uri_Http) {
         return $this->uri->__toString();
     } else {
         return $this->uri;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:Abstract.php

示例13: __construct

 /**
  * 初始化趣乐平台地址
  * 
  * @param string $url
  */
 public function __construct($url = null)
 {
     if (empty($url)) {
         $this->_uri = self::$_defaultUri;
     } else {
         $this->_uri = Zend_Uri_Http::fromString($url);
     }
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:13,代码来源:Qule.php

示例14: isValid

 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param mixed $value the value to validate
  *
  * @throws Zend_Valid_Exception If validation of $value is impossible
  * @return boolean
  */
 public function isValid($value)
 {
     $value = (string) $value;
     $this->_setValue($value);
     if (!Zend_Uri_Http::check($value)) {
         $this->_error(self::MALFORMED_URL);
         return false;
     }
     return true;
 }
开发者ID:JellyBellyDev,项目名称:zle,代码行数:22,代码来源:Uri.php

示例15: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->_config = new binumi_config();
     // We have to use the fromString method because the 'host' we pass in
     // may actually contain a port (e.g. 'blah.com:8080' not just 'blah.com')
     // so we can't just pass it to Zend_Uri_Http.setHost(), like one might
     // expect
     $url = $this->_config->get_scheme() . '://' . $this->_config->get_host();
     $this->_uri = Zend_Uri_Http::fromString($url);
 }
开发者ID:Binumi,项目名称:binumi-moodle,代码行数:13,代码来源:binumi_client.class.php


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