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


PHP Net_URL::resolvePath方法代码示例

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


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

示例1: _redirectUrl

 /**
  * Calculates the absolute URL of a redirect
  *  
  * @param    object  Net_Url object containing the request URL
  * @param    string  Value of the 'Location' response header
  * @return   string|null  Absolute URL we are being redirected to, null in case of non-HTTP URL 
  * @access   private
  */
 function _redirectUrl($url, $location)
 {
     // If it begins with a scheme (as defined in RFC 2396) then it is absolute URI
     if (preg_match('/^([a-zA-Z][a-zA-Z0-9+.-]*):/', $location, $matches)) {
         // Bug #5759: we shouldn't try to follow non-HTTP redirects
         if ('http' == strtolower($matches[1]) || 'https' == strtolower($matches[1])) {
             return $location;
         } else {
             return null;
         }
     } else {
         if ('/' == $location[0]) {
             $url->path = Net_URL::resolvePath($location);
         } elseif ('/' == substr($url->path, -1)) {
             $url->path = Net_URL::resolvePath($url->path . $location);
         } else {
             $dirname = DIRECTORY_SEPARATOR == dirname($url->path) ? '/' : dirname($url->path);
             $url->path = Net_URL::resolvePath($dirname . '/' . $location);
         }
         $url->querystring = array();
         $url->anchor = '';
         return $url->getUrl();
     }
 }
开发者ID:BackupTheBerlios,项目名称:rheinaufcms-svn,代码行数:32,代码来源:Client.php

示例2: sendRequest

 /**
  * Sends the request
  *
  * @access public
  * @param  bool   Whether to store response body in Response object property,
  *                set this to false if downloading a LARGE file and using a Listener
  * @return mixed  PEAR error on error, true otherwise
  */
 function sendRequest($saveBody = true)
 {
     if (!is_a($this->_url, 'Net_URL')) {
         return PEAR::raiseError('No URL given.');
     }
     $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host;
     $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port;
     // 4.3.0 supports SSL connections using OpenSSL. The function test determines
     // we running on at least 4.3.0
     if (strcasecmp($this->_url->protocol, 'https') == 0 and function_exists('file_get_contents') and extension_loaded('openssl')) {
         if (isset($this->_proxy_host)) {
             return PEAR::raiseError('HTTPS proxies are not supported.');
         }
         $host = 'ssl://' . $host;
     }
     // magic quotes may fuck up file uploads and chunked response processing
     $magicQuotes = ini_get('magic_quotes_runtime');
     ini_set('magic_quotes_runtime', false);
     // If this is a second request, we may get away without
     // re-connecting if they're on the same server
     $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions);
     PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest());
     if (!PEAR::isError($err)) {
         if (!empty($this->_readTimeout)) {
             $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]);
         }
         $this->_notify('sentRequest');
         // Read the response
         $this->_response =& new HTTP_Response($this->_sock, $this->_listeners);
         $err = $this->_response->process($this->_saveBody && $saveBody);
     }
     ini_set('magic_quotes_runtime', $magicQuotes);
     if (PEAR::isError($err)) {
         return $err;
     }
     // Check for redirection
     if ($this->_allowRedirects and $this->_redirects <= $this->_maxRedirects and $this->getResponseCode() > 300 and $this->getResponseCode() < 399 and !empty($this->_response->_headers['location'])) {
         $redirect = $this->_response->_headers['location'];
         // Absolute URL
         if (preg_match('/^https?:\\/\\//i', $redirect)) {
             $this->_url =& new Net_URL($redirect);
             $this->addHeader('Host', $this->_generateHostHeader());
             // Absolute path
         } elseif ($redirect[0] == '/') {
             $this->_url->path = $redirect;
             // Relative path
         } elseif (substr($redirect, 0, 3) == '../' or substr($redirect, 0, 2) == './') {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $redirect = Net_URL::resolvePath($redirect);
             $this->_url->path = $redirect;
             // Filename, no path
         } else {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $this->_url->path = $redirect;
         }
         $this->_redirects++;
         return $this->sendRequest($saveBody);
         // Too many redirects
     } elseif ($this->_allowRedirects and $this->_redirects > $this->_maxRedirects) {
         return PEAR::raiseError('Too many redirects');
     }
     $this->_sock->disconnect();
     return true;
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:80,代码来源:Request.php

示例3: convertPath

 function convertPath($in_to, $path)
 {
     // it's a // url (eg. use https if already in https mode...)
     if (preg_match('#^//#', $path)) {
         return $path;
     }
     //print_r(array($this->baseURL, $in_to, $path ));
     require_once 'Net/URL.php';
     $a = new Net_URL();
     $path = $a->resolvePath($this->baseURL . '/' . $path);
     // not sure if that's a good idea..
     $to = rtrim($a->resolvePath($in_to), '/');
     //print_r(array($path,$to));
     $path1 = $path ? explode('/', $path) : array();
     $path2 = $to ? explode('/', $to) : array();
     $shared = array();
     // compare paths & strip identical ancestors
     foreach ($path1 as $i => $chunk) {
         if (isset($path2[$i]) && $path1[$i] == $path2[$i]) {
             $shared[] = $chunk;
         } else {
             break;
         }
     }
     $shared = implode('/', $shared);
     //print_r(array($shared));
     $path = mb_substr($path, mb_strlen($shared));
     $to = mb_substr($to, mb_strlen($shared));
     $to = str_repeat('../', mb_substr_count($to, '/'));
     $ret = $to . ltrim($path, '/');
     //print_r(array($ret));
     return $ret;
 }
开发者ID:roojs,项目名称:pear,代码行数:33,代码来源:Minify.php

示例4: generate

 public function generate($values = array(), $qstring = array(), $anchor = '')
 {
     $path = '';
     foreach ($this->parts as $part) {
         $path .= $part->generate($values);
     }
     $path = '/' . trim(Net_URL::resolvePath($path), '/');
     if (!empty($qstring)) {
         $path .= '?' . http_build_query($qstring);
     }
     if (!empty($anchor)) {
         $path .= '#' . ltrim($anchor, '#');
     }
     return $path;
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:15,代码来源:Path.php

示例5: sendRequest


//.........这里部分代码省略.........
            !empty($sockets[$sockKey]->fp)) 
        {
            $this->_sock =& $sockets[$sockKey];
            $err = null;
        } else {
            $this->_notify('connect');
            $this->_sock = new Net_Socket();
            $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions);
        }
        PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest());

        if (!PEAR::isError($err)) {
            if (!empty($this->_readTimeout)) {
                $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]);
            }

            $this->_notify('sentRequest');

            // Read the response
            $this->_response = new HTTP_Response($this->_sock, $this->_listeners);
            $err = $this->_response->process(
                $this->_saveBody && $saveBody,
                HTTP_REQUEST_METHOD_HEAD != $this->_method
            );

            if ($keepAlive) {
                $keepAlive = (isset($this->_response->_headers['content-length'])
                              || (isset($this->_response->_headers['transfer-encoding'])
                                  && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked'));
                if ($keepAlive) {
                    if (isset($this->_response->_headers['connection'])) {
                        $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive';
                    } else {
                        $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol;
                    }
                }
            }
        }

        ini_set('magic_quotes_runtime', $magicQuotes);

        if (PEAR::isError($err)) {
            return $err;
        }

        if (!$keepAlive) {
            $this->disconnect();
        // Store the connected socket in "static" property
        } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) {
            $sockets[$sockKey] =& $this->_sock;
        }

        // Check for redirection
        if (    $this->_allowRedirects
            AND $this->_redirects <= $this->_maxRedirects
            AND $this->getResponseCode() > 300
            AND $this->getResponseCode() < 399
            AND !empty($this->_response->_headers['location'])) {

            
            $redirect = $this->_response->_headers['location'];

            // Absolute URL
            if (preg_match('/^https?:\/\//i', $redirect)) {
                $this->_url = new Net_URL($redirect);
                $this->addHeader('Host', $this->_generateHostHeader());
            // Absolute path
            } elseif ($redirect{0} == '/') {
                $this->_url->path = $redirect;
            
            // Relative path
            } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') {
                if (substr($this->_url->path, -1) == '/') {
                    $redirect = $this->_url->path . $redirect;
                } else {
                    $redirect = dirname($this->_url->path) . '/' . $redirect;
                }
                $redirect = Net_URL::resolvePath($redirect);
                $this->_url->path = $redirect;
                
            // Filename, no path
            } else {
                if (substr($this->_url->path, -1) == '/') {
                    $redirect = $this->_url->path . $redirect;
                } else {
                    $redirect = dirname($this->_url->path) . '/' . $redirect;
                }
                $this->_url->path = $redirect;
            }

            $this->_redirects++;
            return $this->sendRequest($saveBody);

        // Too many redirects
        } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) {
            return PEAR::raiseError('Too many redirects', HTTP_REQUEST_ERROR_REDIRECTS);
        }

        return true;
    }
开发者ID:rkern21,项目名称:videoeditor,代码行数:101,代码来源:Request.php

示例6: __construct

 /**
  * Instantiate a new MP3_Playlist object.
  *
  * Expects a reading directory, the output directory where the playlist will
  * be saved and the directory or URL to be used within the playlist.
  *
  * @param   string $dir     The directory to scan
  * @param   string $outdir  The directory where to save the playlist file
  * @param   string $baseurl The base url to append on the playlist file
  * @param   bool   $debug   (optional) Whether print debug message or not, default FALSE
  *
  * @return  TRUE|PEAR_Error
  * @see     MP3_Playlist::fixPath()
  */
 public function __construct($dir, $outdir, $baseurl, $debug = false)
 {
     // Taking the values from the constructor and assigning it to the
     // private variables
     $this->parseDirectory = self::fixPath($dir);
     $this->outputDirectory = self::fixPath($outdir);
     // Fix the URL if needed.
     if (substr($baseurl, -1) != '/') {
         $baseurl .= '/';
     }
     $url = new Net_URL($baseurl);
     if (!empty($url->path)) {
         $dirs = explode('/', $url->path);
         foreach ($dirs as $key => $value) {
             if (!empty($value)) {
                 $dirs[$key] = rawurlencode($value);
             }
         }
         $url->path = Net_URL::resolvePath(implode('/', $dirs));
     }
     $this->baseUrl = $url->getURL();
     $this->list = array();
     // Instantiate the new MP3_If object
     $this->mp3 = new MP3_Id();
     $this->debug = $debug;
     $this->parse();
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:41,代码来源:Playlist.php

示例7: _redirectUrl

 /**
  * Calculates the absolute URL of a redirect
  *  
  * @param    object  Net_Url object containing the request URL
  * @param    string  Value of the 'Location' response header
  * @return   string  Absolute URL we are being redirected to
  * @access   private
  */
 function _redirectUrl($url, $location)
 {
     if (preg_match('!^https?://!i', $location)) {
         return $location;
     } else {
         if ('/' == $location[0]) {
             $url->path = Net_URL::resolvePath($location);
         } elseif ('/' == substr($url->path, -1)) {
             $url->path = Net_URL::resolvePath($url->path . $location);
         } else {
             $dirname = DIRECTORY_SEPARATOR == dirname($url->path) ? '/' : dirname($url->path);
             $url->path = Net_URL::resolvePath($dirname . '/' . $location);
         }
         $url->querystring = array();
         $url->anchor = '';
         return $url->getUrl();
     }
 }
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:26,代码来源:Client.php

示例8: sendRequest

 /**
  * Sends the request
  *
  * @access public
  * @return mixed  PEAR error on error, true otherwise
  */
 function sendRequest()
 {
     $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host;
     $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port;
     // 4.3.0 supports SSL connections using OpenSSL. The function test determines
     // we running on at least 4.3.0
     if (strcasecmp($this->_url->protocol, 'https') == 0 and function_exists('file_get_contents') and extension_loaded('openssl')) {
         $host = 'ssl://' . $host;
     }
     // If this is a second request, we may get away without
     // re-connecting if they're on the same server
     if (PEAR::isError($err = $this->_sock->connect($host, $port, null, $this->_timeout)) or PEAR::isError($err = $this->_sock->write($this->_buildRequest()))) {
         return $err;
     }
     // Read the response
     if (PEAR::isError($err = $this->readResponse())) {
         return $err;
     }
     // Check for redirection
     if ($this->_allowRedirects and $this->_redirects <= $this->_maxRedirects and $this->getResponseCode() > 300 and $this->getResponseCode() < 399 and !empty($this->_response->_headers['Location'])) {
         $redirect = $this->_response->_headers['Location'];
         // Absolute URL
         if (preg_match('/^https?:\\/\\//i', $redirect)) {
             $this->_url =& new Net_URL($redirect);
             // Absolute path
         } elseif ($redirect[0] == '/') {
             $this->_url->path = $redirect;
             // Relative path
         } elseif (substr($redirect, 0, 3) == '../' or substr($redirect, 0, 2) == './') {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $redirect = Net_URL::resolvePath($redirect);
             $this->_url->path = $redirect;
             // Filename, no path
         } else {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $this->_url->path = $redirect;
         }
         $this->_redirects++;
         return $this->sendRequest();
         // Too many redirects
     } elseif ($this->_allowRedirects and $this->_redirects > $this->_maxRedirects) {
         return PEAR::raiseError('Too many redirects');
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:lulubot,代码行数:59,代码来源:Request.php

示例9: getAbsoluteUrl

 /**
  * @param  string  $url
  * @param  string  $base_url
  * @return string
  */
 private function getAbsoluteUrl($url, $base_url)
 {
     if (preg_match('/^[\\w\\+\\-\\.]+:/', $url) or false === ($bases = @parse_url($base_url))) {
         return $url;
     } elseif (0 === strpos($url, '/')) {
         return "{$bases['scheme']}://{$bases['host']}" . (isset($bases['port']) ? ":{$bases['port']}" : '') . $url;
     } else {
         if (!isset($bases['path'])) {
             $bases['path'] = '/';
         }
         return "{$bases['scheme']}://{$bases['host']}" . (isset($bases['port']) ? ":{$bases['port']}" : '') . Net_URL::resolvePath(substr($bases['path'], 0, strrpos($bases['path'], '/') + 1) . $url);
     }
 }
开发者ID:diggin-sandbox,项目名称:mirror-htmlscraping-20090114,代码行数:18,代码来源:HTMLScraping.class.php

示例10: sendRequest

 /**
  * Sends the request
  *
  * @access public
  * @param  bool   Whether to store response body in Response object property,
  *                set this to false if downloading a LARGE file and using a Listener
  * @return mixed  PEAR error on error, true otherwise
  */
 function sendRequest($saveBody = true)
 {
     if (!is_a($this->_url, 'Net_URL')) {
         return PEAR::raiseError('No URL given', HTTP_REQUEST_ERROR_URL);
     }
     $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host;
     $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port;
     if (strcasecmp($this->_url->protocol, 'https') == 0) {
         // Bug #14127, don't try connecting to HTTPS sites without OpenSSL
         if (version_compare(PHP_VERSION, '4.3.0', '<') || !extension_loaded('openssl')) {
             return PEAR::raiseError('Need PHP 4.3.0 or later with OpenSSL support for https:// requests', HTTP_REQUEST_ERROR_URL);
         } elseif (isset($this->_proxy_host)) {
             return PEAR::raiseError('HTTPS proxies are not supported', HTTP_REQUEST_ERROR_PROXY);
         }
         $host = 'ssl://' . $host;
     }
     // magic quotes may fuck up file uploads and chunked response processing
     $magicQuotes = ini_get('magic_quotes_runtime');
     ini_set('magic_quotes_runtime', false);
     // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive
     // connection token to a proxy server...
     if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']) {
         $this->removeHeader('connection');
     }
     $keepAlive = HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection']) || !empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection'];
     $sockets =& PEAR::getStaticProperty('HTTP_Request', 'sockets');
     $sockKey = $host . ':' . $port;
     unset($this->_sock);
     // There is a connected socket in the "static" property?
     if ($keepAlive && !empty($sockets[$sockKey]) && !empty($sockets[$sockKey]->fp)) {
         $this->_sock =& $sockets[$sockKey];
         $err = null;
     } else {
         $this->_notify('connect');
         $this->_sock = new Net_Socket();
         $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions);
     }
     PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest());
     if (!PEAR::isError($err)) {
         if (!empty($this->_readTimeout)) {
             $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]);
         }
         $this->_notify('sentRequest');
         // Read the response
         $this->_response = new HTTP_Response($this->_sock, $this->_listeners);
         $err = $this->_response->process($this->_saveBody && $saveBody, HTTP_REQUEST_METHOD_HEAD != $this->_method);
         if ($keepAlive) {
             $keepAlive = isset($this->_response->_headers['content-length']) || isset($this->_response->_headers['transfer-encoding']) && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked';
             if ($keepAlive) {
                 if (isset($this->_response->_headers['connection'])) {
                     $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive';
                 } else {
                     $keepAlive = 'HTTP/' . HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol;
                 }
             }
         }
     }
     ini_set('magic_quotes_runtime', $magicQuotes);
     if (PEAR::isError($err)) {
         return $err;
     }
     if (!$keepAlive) {
         $this->disconnect();
         // Store the connected socket in "static" property
     } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) {
         $sockets[$sockKey] =& $this->_sock;
     }
     // Check for redirection
     if ($this->_allowRedirects and $this->_redirects <= $this->_maxRedirects and $this->getResponseCode() > 300 and $this->getResponseCode() < 399 and !empty($this->_response->_headers['location'])) {
         $redirect = $this->_response->_headers['location'];
         // Absolute URL
         if (preg_match('/^https?:\\/\\//i', $redirect)) {
             $this->_url = new Net_URL($redirect);
             $this->addHeader('Host', $this->_generateHostHeader());
             // Absolute path
         } elseif ($redirect[0] == '/') {
             $this->_url->path = $redirect;
             // Relative path
         } elseif (substr($redirect, 0, 3) == '../' or substr($redirect, 0, 2) == './') {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $redirect = Net_URL::resolvePath($redirect);
             $this->_url->path = $redirect;
             // Filename, no path
         } else {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
//.........这里部分代码省略.........
开发者ID:roojs,项目名称:pear,代码行数:101,代码来源:Request.php

示例11: sendRequest

 /**
  * Sends the request
  *
  * @access public
  * @param  bool   Whether to store response body in Response object property,
  *                set this to false if downloading a LARGE file and using a Listener
  * @return mixed  PEAR error on error, true otherwise
  */
 function sendRequest($saveBody = true)
 {
     if (function_exists('is_a') && !is_a($this->_url, 'Net_URL')) {
         return PEAR::raiseError('No URL given.');
     }
     $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host;
     $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port;
     // 4.3.0 supports SSL connections using OpenSSL. The function test determines
     // we running on at least 4.3.0
     if (strcasecmp($this->_url->protocol, 'https') == 0 and function_exists('file_get_contents') and extension_loaded('openssl')) {
         if (isset($this->_proxy_host)) {
             return PEAR::raiseError('HTTPS proxies are not supported.');
         }
         $host = 'ssl://' . $host;
     }
     // If this is a second request, we may get away without
     // re-connecting if they're on the same server
     if (PEAR::isError($err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions)) || PEAR::isError($err = $this->_sock->write($this->_buildRequest()))) {
         return $err;
     }
     if (!empty($this->_readTimeout)) {
         $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]);
     }
     $this->_notify('sentRequest');
     // Read the response
     $this->_response =& new HTTP_Response($this->_sock, $this->_listeners);
     if (PEAR::isError($err = $this->_response->process($this->_saveBody && $saveBody))) {
         return $err;
     }
     // Check for redirection
     // Bugfix (PEAR) bug #18, 6 oct 2003 by Dave Mertens (headers are also stored lowercase, so we're gonna use them here)
     // some non RFC2616 compliant servers (scripts) are returning lowercase headers ('location: xxx')
     if ($this->_allowRedirects and $this->_redirects <= $this->_maxRedirects and $this->getResponseCode() > 300 and $this->getResponseCode() < 399 and !empty($this->_response->_headers['location'])) {
         $redirect = $this->_response->_headers['location'];
         // Absolute URL
         if (preg_match('/^https?:\\/\\//i', $redirect)) {
             $this->_url =& new Net_URL($redirect);
             $this->addHeader('Host', $this->_generateHostHeader());
             // Absolute path
         } elseif ($redirect[0] == '/') {
             $this->_url->path = $redirect;
             // Relative path
         } elseif (substr($redirect, 0, 3) == '../' or substr($redirect, 0, 2) == './') {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $redirect = Net_URL::resolvePath($redirect);
             $this->_url->path = $redirect;
             // Filename, no path
         } else {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $this->_url->path = $redirect;
         }
         $this->_redirects++;
         return $this->sendRequest($saveBody);
         // Too many redirects
     } elseif ($this->_allowRedirects and $this->_redirects > $this->_maxRedirects) {
         return PEAR::raiseError('Too many redirects');
     }
     $this->_sock->disconnect();
     return true;
 }
开发者ID:koki-h,项目名称:xoops_utf8,代码行数:76,代码来源:Request.php

示例12: sendRequest

 function sendRequest($saveBody = true)
 {
     if (!is_a($this->_url, 'Net_URL')) {
         trigger_error('No URL given.', E_USER_ERROR);
     }
     $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host;
     $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port;
     if (strcasecmp($this->_url->protocol, 'https') == 0 and function_exists('file_get_contents') and extension_loaded('openssl')) {
         if (isset($this->_proxy_host)) {
             trigger_error('HTTPS proxies are not supported.', E_USER_ERROR);
         }
         $host = 'ssl://' . $host;
     }
     $magicQuotes = ini_get('magic_quotes_runtime');
     ini_set('magic_quotes_runtime', false);
     $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions);
     $err = $this->_sock->write($this->_buildRequest());
     if (!empty($this->_readTimeout)) {
         $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]);
     }
     $this->_notify('sentRequest');
     $this->_response =& new HTTP_Response($this->_sock, $this->_listeners);
     $err = $this->_response->process($this->_saveBody && $saveBody);
     ini_set('magic_quotes_runtime', $magicQuotes);
     if ($this->_allowRedirects and $this->_redirects <= $this->_maxRedirects and $this->getResponseCode() > 300 and $this->getResponseCode() < 399 and !empty($this->_response->_headers['location'])) {
         $redirect = $this->_response->_headers['location'];
         if (preg_match('/^https?:\\/\\//i', $redirect)) {
             $this->_url =& new Net_URL($redirect);
             $this->addHeader('Host', $this->_generateHostHeader());
         } elseif ($redirect[0] == '/') {
             $this->_url->path = $redirect;
         } elseif (substr($redirect, 0, 3) == '../' or substr($redirect, 0, 2) == './') {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $redirect = Net_URL::resolvePath($redirect);
             $this->_url->path = $redirect;
         } else {
             if (substr($this->_url->path, -1) == '/') {
                 $redirect = $this->_url->path . $redirect;
             } else {
                 $redirect = dirname($this->_url->path) . '/' . $redirect;
             }
             $this->_url->path = $redirect;
         }
         $this->_redirects++;
         return $this->sendRequest($saveBody);
     } elseif ($this->_allowRedirects and $this->_redirects > $this->_maxRedirects) {
         trigger_error('Too many redirects', E_USER_ERROR);
     }
     $this->_sock->disconnect();
     return true;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:55,代码来源:Request.php


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