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


PHP Zend_Uri_Http::getPath方法代码示例

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


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

示例1: __call

 /**
  * Method call overload
  *
  * @param string $method Method name
  * @param array $args Method args
  * @return Zend_Rest_Client_Result|Zend_Rest_Client
  */
 public function __call($method, $args)
 {
     $methods = array('post', 'get', 'delete', 'put');
     if (in_array(strtolower($method), $methods)) {
         if (!isset($args[0])) {
             $args[0] = $this->_uri->getPath();
         }
         $this->_data['rest'] = 1;
         $response = $this->{'rest' . $method}($args[0], $this->_data);
         $sxml = new Zend_Rest_Client_Result($response->getBody());
         return $sxml;
     } else {
         if (sizeof($args) == 1) {
             // More than one arg means it's definitely a Zend_WebService_Rest_Server
             $this->_data[$method] = $args[0];
             $this->_data['arg1'] = $args[0];
         } else {
             $this->_data['method'] = $method;
             if (sizeof($args) > 0) {
                 foreach ($args as $key => $arg) {
                     $key = 'arg' . $key;
                     $this->_data[$key] = $arg;
                 }
             }
         }
         return $this;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:35,代码来源:Client.php

示例2: __call

 /**
  * Method call overload
  *
  * Allows calling REST actions as object methods; however, you must
  * follow-up by chaining the request with a request to an HTTP request
  * method (post, get, delete, put):
  * <code>
  * $response = $rest->sayHello('Foo', 'Manchu')->get();
  * </code>
  *
  * Or use them together, but in sequential calls:
  * <code>
  * $rest->sayHello('Foo', 'Manchu');
  * $response = $rest->get();
  * </code>
  *
  * @param string $method Method name
  * @param array $args Method args
  * @return Zend_Rest_Client_Result|Zend_Rest_Client Zend_Rest_Client if using
  * a remote method, Zend_Rest_Client_Result if using an HTTP request method
  */
 public function __call($method, $args)
 {
     $methods = array('post', 'get', 'delete', 'put');
     if (in_array(strtolower($method), $methods)) {
         if (!isset($args[0])) {
             $args[0] = $this->_uri->getPath();
         }
         $this->_data['rest'] = 1;
         $data = array_slice($args, 1) + $this->_data;
         $response = $this->{'rest' . $method}($args[0], $data);
         $this->_data = array();
         //Initializes for next Rest method.
         return new Zend_Rest_Client_Result($response->getBody());
     } else {
         // More than one arg means it's definitely a Zend_Rest_Server
         if (sizeof($args) == 1) {
             // Uses first called function name as method name
             if (!isset($this->_data['method'])) {
                 $this->_data['method'] = $method;
                 $this->_data['arg1'] = $args[0];
             }
             $this->_data[$method] = $args[0];
         } else {
             $this->_data['method'] = $method;
             if (sizeof($args) > 0) {
                 foreach ($args as $key => $arg) {
                     $key = 'arg' . $key;
                     $this->_data[$key] = $arg;
                 }
             }
         }
         return $this;
     }
 }
开发者ID:rdallasgray,项目名称:zf,代码行数:55,代码来源:Client.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: needsToken

 /**
  * Check if this request needs token
  * @return bool
  */
 protected function needsToken()
 {
     if (!empty($this->is_request)) {
         return false;
     }
     if (empty($this->requestPath)) {
         return true;
     }
     $GLOBALS['log']->debug("URLs: now: " . $this->url->getUri() . " req: {$this->requestPath}");
     if ($this->requestPath[0] == '/') {
         return $this->url->getPath() != $this->requestPath;
     }
     return $this->url->getUri() != $this->requestPath;
 }
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:18,代码来源:Provider.php

示例5: isMatch

 public function isMatch(Zend_Uri_Http $url)
 {
     if (preg_match($this->getRegularExpression(), $url->getPath(), $params)) {
         // Remove all integer indexed values.
         foreach ($params as $index => $value) {
             if (is_int($index)) {
                 unset($params[$index]);
             }
         }
         /**
          *	Zend_Uri_Http is lacking an getter for the query string as an array
          */
         $queryParams = array();
         if ($url->getQuery() !== false) {
             parse_str($url->getQuery(), $queryParams);
         }
         return array_merge($this->defaults, $queryParams, $params);
     }
     return false;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:YARouter.php

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

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

示例8: 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 = '')
 {
     $host = $uri->getHost();
     $host = strtolower($uri->getScheme()) == 'https' ? 'sslv2://' . $host : $host;
     // 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;
     // Do nothing - just return the request as string
     return $request;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:Test.php

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

示例10: 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 as string
  */
 public function write($method, $uri, $http_ver = 1.1, $headers = array(), $body = '')
 {
     // Make sure we're properly connected
     if (!$this->socket) {
         throw Zend::exception('Zend_Http_Client_Adapter_Exception', "Trying to write but we are not connected");
     }
     $host = $uri->getHost();
     $host = strtolower($uri->getScheme()) == 'https' ? 'sslv2://' . $host : $host;
     if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
         throw Zend::exception('Zend_Http_Client_Adapter_Exception', "Trying to write but we are connected to the wrong host");
     }
     // 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)) {
         throw Zend::exception('Zend_Http_Client_Adapter_Exception', "Error writing request to server");
     }
     return $request;
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:41,代码来源:Socket.php

示例11: deleteCookies

 /**
  * Delete a cookie according to it's name and domain. If no name is specified,
  * all cookies from this domain will be cleared out.
  *
  * @param string|Zend_Uri_Http $domain
  * @param string $cookie_name 
  * @return boolean true if cookie was deleted.
  */
 public function deleteCookies($domain, $cookie_name = null)
 {
     $ret = false;
     $path = '/';
     if ($domain instanceof Zend_Uri_Http) {
         $path = dirname($domain->getPath());
         $domain = $domain->getHost();
     } elseif (is_string($domain) && Zend_Uri_Http::check($domain)) {
         $domain = Zend_Uri_Http::factory($domain);
         $path = dirname($domain->getPath());
         $domain = $domain->getHost();
     }
     // If we have a cookie's name, delete only this one
     if (isset($cookie_name) && isset($this->cookies[$domain][$path][$cookie_name])) {
         unset($this->cookies[$domain][$path][$cookie_name]);
         $ret = true;
         // If we only got a URI, clear all cookies matching this URI.
     } else {
         $cookies = $this->_matchPath($this->_matchDomain($domain), $path);
         foreach ($cookies as $cookie) {
             if (isset($this->cookies[$cookie->getDomain()][$cookie->getPath])) {
                 unset($this->cookies[$cookie->getDomain()][$cookie->getPath]);
                 $ret = true;
                 if (count($this->cookies[$cookie->getDomain()]) == 0) {
                     unset($this->cookies[$cookie->getDomain()]);
                 }
             }
         }
     }
     return $ret;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:39,代码来源:Cookiejar.php

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