Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Http Class Reference

HTTP URI handler. More...

Public Member Functions

 getUser ()
 Get the username part (before the ':') of the userInfo URI part.
 
 getPassword ()
 Get the password part (after the ':') of the userInfo URI part.
 
 getUserInfo ()
 Get the User-info (usually user:password) part.
 
 setUser ($user)
 Set the username part (before the ':') of the userInfo URI part.
 
 setPassword ($password)
 Set the password part (after the ':') of the userInfo URI part.
 
 setUserInfo ($userInfo)
 Set the URI User-info part (usually user:password)
 
 getPort ()
 Return the URI port.
 
 parse ($uri)
 Parse a URI string.
 
- Public Member Functions inherited from Uri
 __construct ($uri=null)
 Create a new URI object.
 
 isValid ()
 Check if the URI is valid.
 
 isValidRelative ()
 Check if the URI is a valid relative URI.
 
 isAbsolute ()
 Check if the URI is an absolute or relative URI.
 
 parse ($uri)
 Parse a URI string.
 
 toString ()
 Compose the URI into a string.
 
 normalize ()
 Normalize the URI.
 
 resolve ($baseUri)
 Convert a relative URI into an absolute URI using a base absolute URI as a reference.
 
 makeRelative ($baseUri)
 Convert the link to a relative link by substracting a base URI.
 
 getScheme ()
 Get the scheme part of the URI.
 
 getUserInfo ()
 Get the User-info (usually user:password) part.
 
 getHost ()
 Get the URI host.
 
 getPort ()
 Get the URI port.
 
 getPath ()
 Get the URI path.
 
 getQuery ()
 Get the URI query.
 
 getQueryAsArray ()
 Return the query string as an associative array of key => value pairs.
 
 getFragment ()
 Get the URI fragment.
 
 setScheme ($scheme)
 Set the URI scheme.
 
 setUserInfo ($userInfo)
 Set the URI User-info part (usually user:password)
 
 setHost ($host)
 Set the URI host.
 
 setPort ($port)
 Set the port part of the URI.
 
 setPath ($path)
 Set the path.
 
 setQuery ($query)
 Set the query string.
 
 setFragment ($fragment)
 Set the URI fragment part.
 
 __toString ()
 Magic method to convert the URI to a string.
 

Static Public Member Functions

static validateHost ($host, $allowed=self::HOST_DNS_OR_IPV4_OR_IPV6)
 Validate the host part of an HTTP URI.
 
- Static Public Member Functions inherited from Uri
static setEscaper (Escaper $escaper)
 Set Escaper instance.
 
static getEscaper ()
 Retrieve Escaper instance.
 
static validateScheme ($scheme)
 Encoding and Validation Methods.
 
static validateUserInfo ($userInfo)
 Check that the userInfo part of a URI is valid.
 
static validateHost ($host, $allowed=self::HOST_ALL)
 Validate the host part.
 
static validatePort ($port)
 Validate the port.
 
static validatePath ($path)
 Validate the path.
 
static validateQueryFragment ($input)
 Check if a URI query or fragment part is valid or not.
 
static encodeUserInfo ($userInfo)
 URL-encode the user info part of a URI.
 
static encodePath ($path)
 Encode the path.
 
static encodeQueryFragment ($input)
 URL-encode a query string or fragment based on RFC-3986 guidelines.
 
static parseScheme ($uriString)
 Extract only the scheme part out of a URI string.
 
static removePathDotSegments ($path)
 Remove any extra dot segments (/../, /.
 
static merge ($baseUri, $relativeUri)
 Merge a base URI and a relative URI into a new URI object.
 

Protected Member Functions

 parseUserInfo ()
 Parse the user info into username and password segments.
 
 buildUserInfo ()
 Build the user info based on user and password.
 
- Protected Member Functions inherited from Uri
 reset ()
 Reset URI parts.
 

Protected Attributes

static $validHostTypes = self::HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME
 
 $user
 
 $password
 
- Protected Attributes inherited from Uri
 $scheme
 
 $userInfo
 
 $host
 
 $port
 
 $path
 
 $query
 
 $fragment
 
 $validHostTypes = self::HOST_ALL
 

Static Protected Attributes

static $validSchemes
 
static $defaultPorts
 
- Static Protected Attributes inherited from Uri
static $validSchemes = []
 
static $defaultPorts = []
 
static $escaper
 

Additional Inherited Members

- Public Attributes inherited from Uri
const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~'
 Character classes defined in RFC-3986.
 
const CHAR_GEN_DELIMS = ':\/\?#\[\]@'
 
const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;='
 
const CHAR_RESERVED = ':\/\?#\[\]@!\$&\'\(\)\*\+,;='
 
const CHAR_QUERY_DELIMS = '!\$\'\(\)\*\,'
 Not in the spec - those characters have special meaning in urlencoded query parameters.
 
const HOST_IPV4 = 0x01
 Host part types represented as binary masks The binary mask consists of 5 bits in the following order: <RegName> | <DNS> | <IPvFuture> | <IPv6> | <IPv4> Place 1 or 0 in the different positions for enable or disable the part.
 
const HOST_IPV6 = 0x02
 
const HOST_IPVFUTURE = 0x04
 
const HOST_IPVANY = 0x07
 
const HOST_DNS = 0x08
 
const HOST_DNS_OR_IPV4 = 0x09
 
const HOST_DNS_OR_IPV6 = 0x0A
 
const HOST_DNS_OR_IPV4_OR_IPV6 = 0x0B
 
const HOST_DNS_OR_IPVANY = 0x0F
 
const HOST_REGNAME = 0x10
 
const HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME = 0x1B
 
const HOST_ALL = 0x1F
 
- Static Protected Member Functions inherited from Uri
static isValidIpAddress ($host, $allowed)
 Check if a host name is a valid IP address, depending on allowed IP address types.
 
static isValidDnsHostname ($host)
 Check if an address is a valid DNS hostname.
 
static isValidRegName ($host)
 Check if an address is a valid registered name (as defined by RFC-3986) address.
 
static normalizeScheme ($scheme)
 Part normalization methods.
 
static normalizeHost ($host)
 Normalize the host part.
 
static normalizePort ($port, $scheme=null)
 Normalize the port.
 
static normalizePath ($path)
 Normalize the path.
 
static normalizeQuery ($query)
 Normalize the query part.
 
static normalizeFragment ($fragment)
 Normalize the fragment part.
 
static decodeUrlEncodedChars ($input, $allowed= '')
 Decode all percent encoded characters which are allowed to be represented literally.
 

Detailed Description

HTTP URI handler.

Member Function Documentation

buildUserInfo ( )
protected

Build the user info based on user and password.

Builds the user info based on the given user and password values

Returns
void
getPassword ( )

Get the password part (after the ':') of the userInfo URI part.

Returns
string|null
getPort ( )

Return the URI port.

If no port is set, will return the default port according to the scheme

Returns
int
See Also
Zend::getPort()

Implements UriInterface.

getUser ( )

Get the username part (before the ':') of the userInfo URI part.

Returns
string|null
getUserInfo ( )

Get the User-info (usually user:password) part.

Returns
string|null

Implements UriInterface.

parse (   $uri)

Parse a URI string.

Parameters
string$uri
Returns
Http

Implements UriInterface.

parseUserInfo ( )
protected

Parse the user info into username and password segments.

Parses the user information into username and password segments, and then sets the appropriate values.

Returns
void
setPassword (   $password)

Set the password part (after the ':') of the userInfo URI part.

Parameters
string$password
Returns
self
setUser (   $user)

Set the username part (before the ':') of the userInfo URI part.

Parameters
string | null$user
Returns
self
setUserInfo (   $userInfo)

Set the URI User-info part (usually user:password)

Parameters
string | null$userInfo
Returns
self
Exceptions
Exception\InvalidUriPartExceptionIf the schema definition does not have this part

Implements UriInterface.

static validateHost (   $host,
  $allowed = self::HOST_DNS_OR_IPV4_OR_IPV6 
)
static

Validate the host part of an HTTP URI.

This overrides the common URI validation method with a DNS or IP only default. Users may still enforce allowing other host types.

Parameters
string$host
int$allowed
Returns
bool

Member Data Documentation

$defaultPorts
staticprotected
Initial value:
= [
'http' => 80
See Also
Uri::$defaultPorts
$password
protected
$user
protected
$validHostTypes = self::HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME
protected
$validSchemes
staticprotected
Initial value:
= [
'http',
'https'
]
See Also
Uri::$validSchemes