PHP WebSocket2 Library
PHP5 Library for browsing web
HttpHeaderManager Class Reference

HTTP headers manager. More...

Public Member Functions

 __construct ($raw_headers= '')
 Constructor. More...
 
 getHeadersArray ()
 Returns HTTP headers array. More...
 
 addHeader ($name, $value)
 Adds new HTTP header. Does not replace headers with the same names. More...
 
 replaceHeader ($name, $value)
 Adds new HTTP header. Replaces headers with the same names. More...
 
 removeHeader ($name)
 Removes all HTTP headers with specified name, if any exist. More...
 
 clearHeaders ()
 Removes all HTTP headers.
 
 getHeader ($name)
 Returns first HTTP header with specified name. More...
 
 getHeaders ($name)
 Returns HTTP headers values array by header name. More...
 
 hasHeader ($name)
 Returns if there is HTTP header with specified name. More...
 
 getContentLength ()
 Returns content length header value. More...
 
 isChunked ()
 Returns true, if HTTP body contents is chunked. More...
 
 getAuthenticationType ()
 Returns required HTTP authentication type (digest or basic). More...
 
 getAuthenticationOptions ()
 Returns HTTP authentication options array. More...
 
 setBasicAuthenticationCredentials ($login, $password)
 Adds basic authentication header. More...
 
 setDigestAuthenticationCredentials (Array $auth_opts, $login, $password, $request_body, $http_method, $request_uri)
 Adds digest authentication header. More...
 
 getRawHeaders ()
 Returns raw HTTP headers string. More...
 

Data Fields

const HTTP_AUTHENTICATION_NONE = 0
 No HTTP authentication required.
 
const HTTP_AUTHENTICATION_BASIC = 1
 HTTP Basic authentication is required.
 
const HTTP_AUTHENTICATION_DIGEST = 2
 HTTP Digest authentication is required.
 

Detailed Description

HTTP headers manager.

Examples:
manual_http_authentication.php, and response_interception.php.

Constructor & Destructor Documentation

__construct (   $raw_headers = '')

Constructor.

Parameters
string$raw_headersRaw HTTP headers string

Member Function Documentation

addHeader (   $name,
  $value 
)

Adds new HTTP header. Does not replace headers with the same names.

Parameters
string$nameHeader name
string$valueHeader value
getAuthenticationOptions ( )

Returns HTTP authentication options array.

Example: Array('realm' => 'My Realm', 'qop' => 'auth', ...)

Return values
ArrayHTTP authentication options array or null, if no authentication needed
getAuthenticationType ( )

Returns required HTTP authentication type (digest or basic).

Return values
intHTTP_AUTHENTICATION_NONE, HTTP_AUTHENTICATION_BASIC or HTTP_AUTHENTICATION_DIGEST
getContentLength ( )

Returns content length header value.

Return values
intContent length header value or null, if there is no such header
getHeader (   $name)

Returns first HTTP header with specified name.

Parameters
string$nameHeader name
Return values
stringHTTP header value or null, if there is no header with specified name
getHeaders (   $name)

Returns HTTP headers values array by header name.

Parameters
string$nameHeader name
Return values
ArrayHTTP headers array, which contains an Array ('header name' => ' header value') for each header
getHeadersArray ( )

Returns HTTP headers array.

Return values
ArrayHTTP headers array, which contains an Array ('header name' => ' header value') for each header
getRawHeaders ( )

Returns raw HTTP headers string.

This string does not contain ending additional EOL.

Return values
stringHTTP Raw HTTP headers string
hasHeader (   $name)

Returns if there is HTTP header with specified name.

Parameters
string$nameHeader name
Return values
boolTrue if there is HTTP header with specified name
isChunked ( )

Returns true, if HTTP body contents is chunked.

Return values
boolTrue if HTTP body contents is chunked
removeHeader (   $name)

Removes all HTTP headers with specified name, if any exist.

Parameters
string$nameHeader name
replaceHeader (   $name,
  $value 
)

Adds new HTTP header. Replaces headers with the same names.

Parameters
string$nameHeader name
string$valueHeader value
setBasicAuthenticationCredentials (   $login,
  $password 
)

Adds basic authentication header.

Parameters
string$loginLogin
string$passwordPassword
setDigestAuthenticationCredentials ( Array  $auth_opts,
  $login,
  $password,
  $request_body,
  $http_method,
  $request_uri 
)

Adds digest authentication header.

Parameters
Array$auth_optsAuthentication data returned by getAuthenticationOptions
string$loginLogin
string$passwordPassword
string$request_bodyFull body of request. Can be null if $auth_opts['qop'] != 'auth-int'
string$http_methodRequest HTTP method
string$request_uriRequest URI
Exceptions
WebRequestExceptionin case of error in options
Examples:
manual_http_authentication.php.

The documentation for this class was generated from the following file: