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


PHP Zend_Uri_Http::setPath方法代码示例

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


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

示例1: _prepareRest

 /**
  * Call a remote REST web service URI and return the Zend_Http_Response object
  *
  * @param  string $path            The path to append to the URI
  * @throws Zend_Rest_Client_Exception
  * @return void
  */
 private function _prepareRest($path)
 {
     // Get the URI object and configure it
     if (!$this->_uri instanceof Zend_Uri_Http) {
         require_once 'Zend/Rest/Client/Exception.php';
         throw new Zend_Rest_Client_Exception('URI object must be set before performing call');
     }
     $uri = $this->_uri->getUri();
     if ($path[0] != '/' && $uri[strlen($uri) - 1] != '/') {
         $path = '/' . $path;
     }
     $this->_uri->setPath($path);
     /**
      * Get the HTTP client and configure it for the endpoint URI.  Do this each time
      * because the Zend_Http_Client instance is shared among all Zend_Service_Abstract subclasses.
      */
     if ($this->_noReset) {
         // if $_noReset we do not want to reset on this request,
         // but we do on any subsequent request
         $this->_noReset = false;
     } else {
         self::getHttpClient()->resetParameters();
     }
     self::getHttpClient()->setUri($this->_uri);
 }
开发者ID:madberry,项目名称:WhiteLabelTransfer,代码行数:32,代码来源:Client.php

示例2: _prepareRest

 /**
  * Call a remote REST web service URI and return the Zend_Http_Response object
  *
  * @param  string $path            The path to append to the URI
  * @throws Zend_Service_Exception
  * @return void
  */
 private final function _prepareRest($path, $query)
 {
     // Get the URI object and configure it
     if (!$this->_uri instanceof Zend_Uri) {
         throw new Zend_Service_Exception('URI object must be set before performing call');
     }
     // @todo this needs to be revisited
     if ($path[0] != '/' && $this->_uri[strlen($this->_uri) - 1] != '/') {
         $path = '/' . $path;
     }
     $this->_uri->setPath($path);
     if (!is_null($query)) {
         $this->_uri->setQuery($query);
     }
     /**
      * Get the HTTP client and configure it for the endpoint URI.  Do this each time
      * because the Zend_Http_Client instance is shared among all Zend_Service_Abstract subclasses.
      */
     self::getHttpClient()->setUri($this->_uri);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:27,代码来源:Rest.php

示例3: _prepareRest

 /**
  * Call a remote REST web service URI and return the Zend_Http_Response object
  *
  * @param  string $path            The path to append to the URI
  * @throws Zend_Rest_Client_Exception
  * @return void
  */
 private final function _prepareRest($path)
 {
     // Get the URI object and configure it
     if (!$this->_uri instanceof Zend_Uri_Http) {
         require_once 'Zend/Rest/Client/Exception.php';
         throw new Zend_Rest_Client_Exception('URI object must be set before performing call');
     }
     list($path, $query) = explode("?", $path);
     $uri = $this->_uri->getUri();
     if ($path[0] != '/') {
         $path = $this->_basepath . $path;
     }
     $this->_uri->setPath($path);
     $this->_uri->setQuery($query);
     /**
      * Get the HTTP client and configure it for the endpoint URI.  Do this each time
      * because the Zend_Http_Client instance is shared among all Zend_Service_Abstract subclasses.
      */
     self::getHttpClient()->resetParameters()->setUri($this->_uri);
 }
开发者ID:BGCX261,项目名称:zrails-svn-to-git,代码行数:27,代码来源:Client.php

示例4: search

 /**
  * Performs a Twitter search query.
  *
  * @throws Zend_Http_Client_Exception
  */
 public function search($query, array $params = array())
 {
     $this->_uri->setPath('/search.' . $this->_responseType);
     $this->_uri->setQuery(null);
     $_query = array();
     $_query['q'] = $query;
     foreach ($params as $key => $param) {
         switch ($key) {
             case 'geocode':
             case 'lang':
             case 'since_id':
                 $_query[$key] = $param;
                 break;
             case 'rpp':
                 $_query[$key] = intval($param) > 100 ? 100 : intval($param);
                 break;
             case 'page':
                 $_query[$key] = intval($param);
                 break;
             case 'show_user':
                 $_query[$key] = 'true';
         }
     }
     $this->_uri->setQuery($_query);
     $this->setUri($this->_uri);
     $response = $this->request();
     switch ($this->_responseType) {
         case 'json':
             return Zend_Json::decode($response->getBody());
             break;
         case 'atom':
             return Zend_Feed::importString($response->getBody());
             break;
     }
     return;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:41,代码来源:Search.php

示例5: request


//.........这里部分代码省略.........
                 if ($this->_queryBracketsEscaped) {
                     $query = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query);
                 } else {
                     $query = preg_replace('/\\[(?:[0-9]|[1-9][0-9]+)\\]=/', '=', $query);
                 }
             }
             $uri->setQuery($query);
         }
         $body = $this->_prepareBody();
         $headers = $this->_prepareHeaders();
         // check that adapter supports streaming before using it
         if (is_resource($body) && !$this->adapter instanceof Zend_Http_Client_Adapter_Stream) {
             /** @see Zend_Http_Client_Exception */
             require_once 'Zend/Http/Client/Exception.php';
             throw new Zend_Http_Client_Exception('Adapter does not support streaming');
         }
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
         if ($this->config['output_stream']) {
             if ($this->adapter instanceof Zend_Http_Client_Adapter_Stream) {
                 $stream = $this->_openTempStream();
                 $this->adapter->setOutputStream($stream);
             } else {
                 /** @see Zend_Http_Client_Exception */
                 require_once 'Zend/Http/Client/Exception.php';
                 throw new Zend_Http_Client_Exception('Adapter does not support streaming');
             }
         }
         $this->last_request = $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
         $response = $this->adapter->read();
         if (!$response) {
             /** @see Zend_Http_Client_Exception */
             require_once 'Zend/Http/Client/Exception.php';
             throw new Zend_Http_Client_Exception('Unable to read response, or response is empty');
         }
         if ($this->config['output_stream']) {
             $streamMetaData = stream_get_meta_data($stream);
             if ($streamMetaData['seekable']) {
                 rewind($stream);
             }
             // cleanup the adapter
             $this->adapter->setOutputStream(null);
             $response = Zend_Http_Response_Stream::fromStream($response, $stream);
             $response->setStreamName($this->_stream_name);
             if (!is_string($this->config['output_stream'])) {
                 // we used temp name, will need to clean up
                 $response->setCleanup(true);
             }
         } else {
             $response = Zend_Http_Response::fromString($response);
         }
         if ($this->config['storeresponse']) {
             $this->last_response = $response;
         }
         // Load cookies into cookie jar
         if (isset($this->cookiejar)) {
             $this->cookiejar->addCookiesFromResponse($response, $uri, $this->config['encodecookies']);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
             // Avoid problems with buggy servers that add whitespace at the
             // end of some headers (See ZF-11283)
             $location = trim($location);
             // Check whether we send the exact same request again, or drop the parameters
             // and send a GET request
             if ($response->getStatus() == 303 || !$this->config['strictredirects'] && ($response->getStatus() == 302 || $response->getStatus() == 301)) {
                 $this->resetParameters();
                 $this->setMethod(self::GET);
             }
             // If we got a well formed absolute URI
             if (($scheme = substr($location, 0, 6)) && ($scheme == 'http:/' || $scheme == 'https:')) {
                 $this->setHeaders('host', null);
                 $this->setUri($location);
             } else {
                 // Split into path and query and set the query
                 if (strpos($location, '?') !== false) {
                     list($location, $query) = explode('?', $location, 2);
                 } else {
                     $query = '';
                 }
                 $this->uri->setQuery($query);
                 // Else, if we got just an absolute path, set it
                 if (strpos($location, '/') === 0) {
                     $this->uri->setPath($location);
                     // Else, assume we have a relative path
                 } else {
                     // Get the current path directory, removing any trailing slashes
                     $path = $this->uri->getPath();
                     $path = rtrim(substr($path, 0, strrpos($path, '/')), "/");
                     $this->uri->setPath($path . '/' . $location);
                 }
             }
             ++$this->redirectCounter;
         } else {
             // If we didn't get any location, stop redirecting
             break;
         }
     } while ($this->redirectCounter < $this->config['maxredirects']);
     return $response;
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:101,代码来源:Client.php

示例6: request

 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return Zend_Http_Response
  * @throws Zend_Http_Client_Exception
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Zend_Uri_Http) {
         /** @see Zend_Http_Client_Exception */
         require_once 'Zend/Http/Client/Exception.php';
         throw new Zend_Http_Client_Exception('No valid URI has been passed to the client');
     }
     if ($method) {
         $this->setMethod($method);
     }
     $this->redirectCounter = 0;
     $response = null;
     // Make sure the adapter is loaded
     if ($this->adapter == null) {
         $this->setAdapter($this->config['adapter']);
     }
     // Send the first request. If redirected, continue.
     do {
         // Clone the URI and add the additional GET parameters to it
         $uri = clone $this->uri;
         if (!empty($this->paramsGet)) {
             $query = $uri->getQuery();
             if (!empty($query)) {
                 $query .= '&';
             }
             $query .= http_build_query($this->paramsGet, null, '&');
             $uri->setQuery($query);
         }
         $body = $this->_prepareBody();
         $headers = $this->_prepareHeaders();
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
         $this->last_request = $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
         $response = $this->adapter->read();
         if (!$response) {
             /** @see Zend_Http_Client_Exception */
             require_once 'Zend/Http/Client/Exception.php';
             throw new Zend_Http_Client_Exception('Unable to read response, or response is empty');
         }
         $response = Zend_Http_Response::fromString($response);
         if ($this->config['storeresponse']) {
             $this->last_response = $response;
         }
         // Load cookies into cookie jar
         if (isset($this->cookiejar)) {
             $this->cookiejar->addCookiesFromResponse($response, $uri);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
             // Check whether we send the exact same request again, or drop the parameters
             // and send a GET request
             if ($response->getStatus() == 303 || !$this->config['strictredirects'] && ($response->getStatus() == 302 || $response->getStatus() == 301)) {
                 $this->resetParameters();
                 $this->setMethod(self::GET);
             }
             // If we got a well formed absolute URI
             if (Zend_Uri_Http::check($location)) {
                 $this->setHeaders('host', null);
                 $this->setUri($location);
             } else {
                 // Split into path and query and set the query
                 if (strpos($location, '?') !== false) {
                     list($location, $query) = explode('?', $location, 2);
                 } else {
                     $query = '';
                 }
                 $this->uri->setQuery($query);
                 // Else, if we got just an absolute path, set it
                 if (strpos($location, '/') === 0) {
                     $this->uri->setPath($location);
                     // Else, assume we have a relative path
                 } else {
                     // Get the current path directory, removing any trailing slashes
                     $path = $this->uri->getPath();
                     $path = rtrim(substr($path, 0, strrpos($path, '/')), "/");
                     $this->uri->setPath($path . '/' . $location);
                 }
             }
             ++$this->redirectCounter;
         } else {
             // If we didn't get any location, stop redirecting
             break;
         }
     } while ($this->redirectCounter < $this->config['maxredirects']);
     return $response;
 }
开发者ID:Mendim,项目名称:gtv-resources,代码行数:93,代码来源:Client.php

示例7: generateUrl

 public function generateUrl($parameters, Zend_Uri_Http $url)
 {
     $parts = $this->getParts();
     $n = count($parts);
     $path = $parts[0];
     for ($i = 1; $i < $n; $i += 3) {
         $type = $parts[$i];
         $name = $parts[$i + 1];
         $static = $parts[$i + 2];
         if (isset($parameters[$name])) {
             $path .= $this->encode($type, $parameters[$name]);
             unset($parameters[$name]);
         } else {
             if (array_key_exists($name, $this->defaults)) {
                 if (is_null($this->defaults[$name])) {
                     // Remove rest of params so they dont appear in querystring
                     for (; $i < $n; $i += 3) {
                         unset($parameters[$parts[$i + 1]]);
                     }
                     break;
                 } else {
                     $path .= $this->encode($type, $this->defaults[$name]);
                 }
             } else {
                 throw new Zend_Controller_Router_Exception("Missing required parameter {$name}");
             }
         }
         $path .= $static;
     }
     // Validate the path (and therefore parameters used so far) for this route
     if (0 == preg_match($this->getRegularExpression(), $path)) {
         throw new Zend_Controller_Router_Exception("{$path} does not match route {$this->getName()} {$this->getRegularExpression()}");
     }
     // Remove parameters that are at their defaults for this route
     if (!empty($this->defaults)) {
         $parameters = array_diff_assoc($parameters, $this->defaults);
     }
     $url->setPath($path);
     $url->setQueryArray($parameters);
     return $url;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:41,代码来源:YARouter.php

示例8: request

 /**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return Zend_Http_Response
  */
 public function request($method = null)
 {
     if (!$this->uri instanceof Zend_Uri_Http) {
         throw new Zend_Http_Client_Exception("No valid URI has been passed to the client");
     }
     if ($method) {
         $this->setMethod($method);
     }
     $this->redirectCounter = 0;
     $response = null;
     // Send the first request. If redirected, continue.
     do {
         // Clone the URI and add the additional GET parameters to it
         $uri = clone $this->uri;
         $uri_params = array();
         parse_str($uri->getQuery(), $uri_params);
         $uri->setQuery(array_merge($uri_params, $this->paramsGet));
         $body = $this->prepare_body();
         $headers = $this->prepare_headers();
         $request = implode("\r\n", $headers) . "\r\n" . $body;
         $this->last_request = $request;
         // Open the connection, send the request and read the response
         $this->adapter->connect($uri->getHost(), $uri->getPort(), $uri->getScheme() == 'https' ? true : false);
         $this->adapter->write($this->method, $uri, $this->config['httpversion'], $headers, $body);
         $response = Zend_Http_Response::factory($this->adapter->read());
         // Load cookies into cookie jar
         if (isset($this->Cookiejar)) {
             $this->Cookiejar->addCookiesFromResponse($response, $uri);
         }
         // If we got redirected, look for the Location header
         if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
             // Check whether we send the exact same request again, or drop the parameters
             // and send a GET request
             if ($response->getStatus() == 303 || !$this->config['strictredirects'] && ($response->getStatus() == 302 || $response->getStatus() == 301)) {
                 $this->resetParameters();
                 $this->setMethod(self::GET);
             }
             // If we got a well formed absolute URI
             if (Zend_Uri_Http::check($location)) {
                 $this->setHeaders('host', null);
                 $this->setUri($location);
             } else {
                 // Split into path and query and set the query
                 list($location, $query) = explode('?', $location, 2);
                 $this->uri->setQueryString($query);
                 // Else, if we got just an absolute path, set it
                 if (strpos($location, '/') === 0) {
                     $this->uri->setPath($location);
                     // Else, assume we have a relative path
                 } else {
                     // Get the current path directory, removing any trailing slashes
                     $path = rtrim(dirname($this->uri->getPath()), "/");
                     $this->uri->setPath($path . '/' . $location);
                 }
             }
             $this->redirectCounter++;
         } else {
             // If we didn't get any location, stop redirecting
             break;
         }
     } while ($this->redirectCounter < $this->config['maxredirects']);
     return $response;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:69,代码来源:Client.php


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