PHP WebSocket2 Library
PHP5 Library for browsing web
HttpParamManager Class Reference

HTTP GET/POST parameters manager. More...

Inheritance diagram for HttpParamManager:

Public Member Functions

 setAutoUrlEncode ($url_encode)
 Enables or disables auto urlencode of parameter names and values. More...
 
 isAutoUrlEncodeEnabled ()
 Returns true if auto urlencode of parameter names and values is enabled. More...
 
 hasAttachments ()
 Returns true if any of parameters are attachments. More...
 
 getParams ($param_type)
 Returns array of parameters of specified type. More...
 
 setParam ($name, $value, $get_only=false)
 Adds new parameter or replaces parameter with same name. More...
 
 hasParam ($name)
 Returns true if parameter with specified name exists. More...
 
 getParam ($name)
 Returns parameter value by name. More...
 
 removeParam ($name)
 Removes parameter by name. More...
 
 offsetExists ($offset)
 Returns true if parameter with specified name exists. More...
 
 offsetGet ($offset)
 Returns parameter value by name. More...
 
 offsetSet ($offset, $value)
 Adds new parameter or replaces parameter with same name. More...
 
 offsetUnset ($offset)
 Removes parameter by name. More...
 
 getRawFileData (HttpSocket $socket, $boundary)
 Writes raw file data of attachments to socket. Moreover, writes ending boundary for multipart/form-data request. More...
 
 getRawFileDataLength ($boundary)
 Returns length in bytes of raw file data of attachments. More...
 
 getRawParamString ($param_type, $boundary=null)
 Returns raw parameter names and values string, which is ready to be sent to socket. More...
 

Data Fields

const ALL_PARAMS = 0
 All parameter types. More...
 
const GET_ONLY_PARAMS = 1
 Parameters that will be passed to server with GET method only. More...
 
const NON_GET_ONLY_PARAMS = 2
 Parameters that will be passed to server with POST/PUT method only. More...
 

Detailed Description

HTTP GET/POST parameters manager.

By default, auto urlencode of parameter names and values is enabled.

Member Function Documentation

getParam (   $name)

Returns parameter value by name.

Parameters
string$nameParameter name
Return values
mixedParameter value or null, if no parameter found
getParams (   $param_type)

Returns array of parameters of specified type.

Parameters
int$param_typeParameter type. See ALL_PARAMS, GET_ONLY_PARAMS, NON_GET_ONLY_PARAMS
Return values
ArrayArray of parameters, where keys are parameter names and values are parameter values.
getRawFileData ( HttpSocket  $socket,
  $boundary 
)

Writes raw file data of attachments to socket. Moreover, writes ending boundary for multipart/form-data request.

Call this function only after getRawParamString and in case param manager has any attachments.

Parameters
HttpSocket$socketSocket to write data to
string$boundaryHTTP boundary. Must be the same as supplied to getRawParamString function
getRawFileDataLength (   $boundary)

Returns length in bytes of raw file data of attachments.

Parameters
string$boundaryHTTP boundary
Return values
intLength in bytes of raw file data of attachments
getRawParamString (   $param_type,
  $boundary = null 
)

Returns raw parameter names and values string, which is ready to be sent to socket.

Does not include attachments. If any attachments are present, getRawFileData must be called after getRawParamString to send all file data of attachments.

Parameters
int$param_typeParameter type. See ALL_PARAMS, GET_ONLY_PARAMS, NON_GET_ONLY_PARAMS
string$boundaryParameter boundary. Boundary is used if any attachments are present. If $param_type is GET_ONLY_PARAMS or there are no attachments, boundary can be null
Return values
stringRaw parameter string ready to be used in any HTTP request
hasAttachments ( )

Returns true if any of parameters are attachments.

Return values
boolTrue if any of parameters are attachments
hasParam (   $name)

Returns true if parameter with specified name exists.

Parameters
string$nameParameter name
Return values
boolTrue if parameter with specified name exists
isAutoUrlEncodeEnabled ( )

Returns true if auto urlencode of parameter names and values is enabled.

Return values
boolTrue if auto urlencode of parameter names and values is enabled
offsetExists (   $offset)

Returns true if parameter with specified name exists.

Overload for ArrayAccess interface.

Parameters
string$offsetParameter name
Return values
boolTrue if parameter with specified name exists
offsetGet (   $offset)

Returns parameter value by name.

Overload for ArrayAccess interface.

Parameters
string$offsetParameter name
Return values
mixedParameter value or null, if no parameter found
offsetSet (   $offset,
  $value 
)

Adds new parameter or replaces parameter with same name.

Overload for ArrayAccess interface.

Parameters
string$offsetParameter name
mixed$valueParameter value. This can be string, int, float, bool or HttpAttachment or Array of strings, int's, float's, bool's and/or HttpAttachment's
offsetUnset (   $offset)

Removes parameter by name.

If no parameter found, does nothing.

Overload for ArrayAccess interface.

Parameters
string$offsetParameter name
removeParam (   $name)

Removes parameter by name.

If no parameter found, does nothing.

Parameters
string$nameParameter name
setAutoUrlEncode (   $url_encode)

Enables or disables auto urlencode of parameter names and values.

Parameters
bool$url_encodeTrue to enable auto urlencode of parameter names and values
setParam (   $name,
  $value,
  $get_only = false 
)

Adds new parameter or replaces parameter with same name.

Parameters
string$nameParameter name
mixed$valueParameter value. This can be string, int, float, bool or HttpAttachment or Array of strings, int's, float's, bool's and/or HttpAttachment's
bool$get_onlyIf true, this parameter will be passed only with GET method.

Field Documentation

const ALL_PARAMS = 0

All parameter types.

Used in getParams, getRawParamString

const GET_ONLY_PARAMS = 1

Parameters that will be passed to server with GET method only.

Used in getParams, getRawParamString

const NON_GET_ONLY_PARAMS = 2

Parameters that will be passed to server with POST/PUT method only.

Used in getParams, getRawParamString


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