Uri/Http.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Uri
- Version
- $Id: Http.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Uri_Http
HTTP(S) URI handler
- Parent(s)
- \Zend_Uri
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Uses
- \global\Zend_Uri
Constants
Properties


array $_config = array('allow_unwise' => false)
array('allow_unwise' => false)
Details- Type
- array
- Inherited_from
- \Zend_Uri::$$_config


array $_regex = array()
Regular expression grammar rules for validation; values added by constructor
array()
Details- Type
- array
Methods


__construct(string $scheme, string $schemeSpecific = '') : void
Constructor accepts a string $scheme (e.g., http, https) and a scheme-specific part of the URI (e.g., example.com/path/to/resource?query=param#fragment)
Use Zend_Uri::factory() to return a new Zend_Uri object.
Name | Type | Description |
---|---|---|
$scheme | string | The scheme of the URI |
$schemeSpecific | string | The scheme-specific part of the URI |
Exception | Description |
---|---|
\Zend_Uri_Exception | When the URI is not valid |


_parseUri(string $schemeSpecific) : void
Parse the scheme-specific portion of the URI and place its parts into instance variables.
Name | Type | Description |
---|---|---|
$schemeSpecific | string | The scheme-specific portion to parse |
Exception | Description |
---|---|
\Zend_Uri_Exception | When scheme-specific decoposition fails |
\Zend_Uri_Exception | When authority decomposition fails |


addReplaceQueryParameters(array $queryParams) : string
Add or replace params in the query string for the current URI, and return the old query.
Name | Type | Description |
---|---|---|
$queryParams | array |
Type | Description |
---|---|
string | Old query string |


check(string $uri) : boolean
Convenience function, checks that a $uri string is well-formed by validating it but not returning an object.
Inherited from: \Zend_Uri::check()Returns TRUE if $uri is a well-formed URI, or FALSE otherwise.
Name | Type | Description |
---|---|---|
$uri | string | The URI to check |
Type | Description |
---|---|
boolean |


factory(string $uri = 'http', string $className = null) : \Zend_Uri
If building a new URI, then $uri should contain only the scheme (http, ftp, etc). Otherwise, supply $uri with the complete URI.
Name | Type | Description |
---|---|---|
$uri | string | The URI form which a Zend_Uri instance is created |
$className | string | The name of the class to use in order to manipulate URI |
Type | Description |
---|---|
\Zend_Uri |
Exception | Description |
---|---|
\Zend_Uri_Exception | When an empty string was supplied for the scheme |
\Zend_Uri_Exception | When an illegal scheme is supplied |
\Zend_Uri_Exception | When the scheme is not supported |
\Zend_Uri_Exception | When $className doesn't exist or doesn't implements Zend_Uri |


fromString(string $uri) : \Zend_Uri_Http
Creates a Zend_Uri_Http from the given string
Name | Type | Description |
---|---|---|
$uri | string | String to create URI from, must start with 'http://' or 'https://' |
Type | Description |
---|---|
\Zend_Uri_Http |
Exception | Description |
---|---|
\InvalidArgumentException | When the given $uri is not a string or does not start with http:// or https:// |
\Zend_Uri_Exception | When the given $uri is invalid |


getFragment() : string | false
Returns the fragment portion of the URL (after #), or FALSE if none.
Type | Description |
---|---|
string | false |


getHost() : string
Returns the domain or host IP portion of the URL, or FALSE if none.
Type | Description |
---|---|
string |


getPassword() : string
Returns the password portion of the URL, or FALSE if none.
Type | Description |
---|---|
string |


getQuery() : string
Returns the query portion of the URL (after ?), or FALSE if none.
Type | Description |
---|---|
string |


getQueryAsArray() : array
Returns the query portion of the URL (after ?) as a key-value-array.
If the query is empty an empty array is returned
Type | Description |
---|---|
array |


getScheme() : string | false
Type | Description |
---|---|
string | false | Scheme or false if no scheme is set. |


getUri() : string
Returns a URI based on current values of the instance variables.
If any part of the URI does not pass validation, then an exception is thrown.
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When one or more parts of the URI are invalid |


getUsername() : string
Returns the username portion of the URL, or FALSE if none.
Type | Description |
---|---|
string |


removeQueryParameters(array $queryParamKeys) : string
Remove params in the query string for the current URI, and return the old query.
Name | Type | Description |
---|---|---|
$queryParamKeys | array |
Type | Description |
---|---|
string | Old query string |


setConfig(\Zend_Config | array $config) : void
Name | Type | Description |
---|---|---|
$config | \Zend_Config | array |


setFragment(string $fragment) : string
Sets the fragment for the current URI, and returns the old fragment
Name | Type | Description |
---|---|---|
$fragment | string | Fragment of the current URI |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $fragment is not a valid HTTP fragment |


setHost(string $host) : string
Sets the host for the current URI, and returns the old host
Name | Type | Description |
---|---|---|
$host | string | The HTTP host |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $host is nota valid HTTP host |


setPassword(string $password) : string
Sets the password for the current URI, and returns the old password
Name | Type | Description |
---|---|---|
$password | string | The HTTP password |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $password is not a valid HTTP password |


setPath(string $path) : string
Sets the path for the current URI, and returns the old path
Name | Type | Description |
---|---|---|
$path | string | The HTTP path |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $path is not a valid HTTP path |


setPort(string $port) : string
Sets the port for the current URI, and returns the old port
Name | Type | Description |
---|---|---|
$port | string | The HTTP port |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $port is not a valid HTTP port |


setQuery(string | array $query) : string
Set the query string for the current URI, and return the old query string This method accepts both strings and arrays.
Name | Type | Description |
---|---|---|
$query | string | array | The query string or array |
Type | Description |
---|---|
string | Old query string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $query is not a valid query string |


setUsername(string $username) : string
Sets the username for the current URI, and returns the old username
Name | Type | Description |
---|---|---|
$username | string | The HTTP username |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $username is not a valid HTTP username |


valid() : boolean
Validate the current URI from the instance variables.
Returns true if and only if all parts pass validation.
Type | Description |
---|---|
boolean |


validateFragment(string $fragment = null) : boolean
Returns true if and only if the fragment passes validation.
If no fragment is passed, then the fragment contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$fragment | string | Fragment of an URI |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When fragment validation fails |


validateHost(string $host = null) : boolean
Returns true if and only if the host string passes validation.
If no host is passed, then the host contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$host | string | The HTTP host |
Type | Description |
---|---|
boolean |
- Uses
- \global\Zend_Filter


validatePassword(string $password = null) : boolean
Returns true if and only if the password passes validation.
If no password is passed, then the password contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$password | string | The HTTP password |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When password validation fails |


validatePath(string $path = null) : boolean
Returns true if and only if the path string passes validation.
If no path is passed, then the path contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$path | string | The HTTP path |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When path validation fails |


validatePort(string $port = null) : boolean
Returns true if and only if the TCP port string passes validation.
If no port is passed, then the port contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$port | string | The HTTP port |
Type | Description |
---|---|
boolean |


validateQuery(string $query = null) : boolean
Returns true if and only if the query string passes validation.
If no query is passed, then the query string contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$query | string | The query to validate |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When query validation fails |


validateUsername(string $username = null) : boolean
Returns true if and only if the username passes validation.
If no username is passed, then the username contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$username | string | The HTTP username |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When username validation fails |