default
[ class tree: default ] [ index: default ] [ all elements ]

Class: HTTP_Request

Source Location: /pear/HTTP/Request.php

Class Overview




Variables

Methods



Class Details

[line 61]


[ Top ]


Class Variables

$_allowRedirects =

[line 169]

Whether to allow redirects


Type:   boolean


[ Top ]

$_body =

[line 139]

Request body


Type:   string


[ Top ]

$_bodyDisallowed = array('TRACE')

[line 145]

A list of methods that MUST NOT have a request body, per RFC 2616


Type:   array


[ Top ]

$_http =

[line 79]

HTTP Version


Type:   string


[ Top ]

$_listeners = array()

[line 193]

Attached listeners


Type:   array


[ Top ]

$_maxRedirects =

[line 175]

Maximum redirects allowed


Type:   integer


[ Top ]

$_method =

[line 73]

Type of request


Type:   string


[ Top ]

$_pass =

[line 97]

Basic Auth Password


Type:   string


[ Top ]

$_postData =

[line 133]

Post data


Type:   array


[ Top ]

$_postFiles = array()

[line 151]

Files to post


Type:   array


[ Top ]

$_proxy_host =

[line 109]

Proxy server


Type:   string


[ Top ]

$_proxy_pass =

[line 127]

Proxy password


Type:   string


[ Top ]

$_proxy_port =

[line 115]

Proxy port


Type:   integer


[ Top ]

$_proxy_user =

[line 121]

Proxy username


Type:   string


[ Top ]

$_readTimeout =  null

[line 205]

Timeout for reading from socket (array(seconds, microseconds))


Type:   array


[ Top ]

$_redirects =

[line 181]

Current number of redirects


Type:   integer


[ Top ]

$_requestHeaders =

[line 85]

Request headers


Type:   array


[ Top ]

$_response =

[line 163]

HTTP_Response object




[ Top ]

$_saveBody =  true

[line 199]

Whether to save response body in response object property


Type:   bool


[ Top ]

$_sock =

[line 103]

Socket object


Type:   object Net_Socket


[ Top ]

$_socketOptions =  null

[line 211]

Options to pass to Net_Socket::connect. See stream_context_create


Type:   array


[ Top ]

$_timeout =

[line 157]

Connection timeout.


Type:   float


[ Top ]

$_url =

[line 67]

Instance of Net_URL


Type:   object Net_URL


[ Top ]

$_useBrackets =  true

[line 187]

Whether to append brackets [] to array variables


Type:   bool


[ Top ]

$_user =

[line 91]

Basic Auth Username


Type:   string


[ Top ]



Class Methods


constructor HTTP_Request [line 238]

HTTP_Request HTTP_Request( [string $url = ''], [array $params = array()])

Constructor

Sets up the object




Tags:

access:  public


Parameters:

string   $url   The url to fetch/access
array   $params   Associative array of parameters which can have the following keys:
  • method - Method to use, GET, POST etc (string)
  • http - HTTP Version to use, 1.0 or 1.1 (string)
  • user - Basic Auth username (string)
  • pass - Basic Auth password (string)
  • proxy_host - Proxy server host (string)
  • proxy_port - Proxy server port (integer)
  • proxy_user - Proxy auth username (string)
  • proxy_pass - Proxy auth password (string)
  • timeout - Connection timeout in seconds (float)
  • allowRedirects - Whether to follow redirects or not (bool)
  • maxRedirects - Max number of redirects to follow (integer)
  • useBrackets - Whether to append [] to array variable names (bool)
  • saveBody - Whether to save response body in response object property (bool)
  • readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))
  • socketOptions - Options to pass to Net_Socket object (array)

[ Top ]

method addCookie [line 588]

void addCookie( string $name, string $value)

Appends a cookie to "Cookie:" header



Tags:

access:  public


Parameters:

string   $name   cookie name
string   $value   cookie value

[ Top ]

method addFile [line 525]

bool addFile( string $inputName, mixed $fileName, [mixed $contentType = 'application/octet-stream'])

Adds a file to upload

This also changes content-type to 'multipart/form-data' for proper upload




Tags:

return:  true on success
throws:  PEAR_Error
access:  public


Parameters:

string   $inputName   name of file-upload field
mixed   $fileName   file name(s)
mixed   $contentType   content-type(s) of file(s) being uploaded

[ Top ]

method addHeader [line 432]

void addHeader( string $name, string $value)

Adds a request header



Tags:

access:  public


Parameters:

string   $name   Header name
string   $value   Header value

[ Top ]

method addPostData [line 483]

void addPostData( string $name, string $value, [bool $preencoded = false])

Adds postdata items



Tags:

access:  public


Parameters:

string   $name   Post data name
string   $value   Post data value
bool   $preencoded   Whether data is already urlencoded or not, default = not

[ Top ]

method addQueryString [line 458]

void addQueryString( string $name, string $value, [bool $preencoded = false])

Adds a querystring parameter



Tags:

access:  public


Parameters:

string   $name   Querystring parameter name
string   $value   Querystring parameter value
bool   $preencoded   Whether the value is already urlencoded or not, default = not

[ Top ]

method addRawPostData [line 552]

void addRawPostData( string $postdata, [bool $preencoded = true])

Adds raw postdata (DEPRECATED)



Tags:

deprecated:  deprecated since 1.3.0, method setBody() should be used instead
access:  public


Parameters:

string   $postdata   The data
bool   $preencoded   Whether data is preencoded or not, default = already encoded

[ Top ]

method addRawQueryString [line 470]

void addRawQueryString( string $querystring, [bool $preencoded = true])

Sets the querystring to literally what you supply



Tags:

access:  public


Parameters:

string   $querystring   The querystring data. Should be of the format foo=bar&x=y etc
bool   $preencoded   Whether data is already urlencoded or not, default = already encoded

[ Top ]

method attach [line 961]

boolean attach( object HTTP_Request_Listener &$listener)

Adds a Listener to the list of listeners that are notified of the object's events



Tags:

return:  whether the listener was successfully attached
access:  public


Parameters:

object HTTP_Request_Listener   &$listener   instance to attach

[ Top ]

method clearCookies [line 602]

void clearCookies( )

Clears any cookies that have been added (DEPRECATED).

Useful for multiple request scenarios




Tags:

deprecated:  deprecated since 1.2
access:  public


[ Top ]

method clearPostData [line 576]

void clearPostData( )

Clears any postdata that has been added (DEPRECATED).

Useful for multiple request scenarios.




Tags:

deprecated:  deprecated since 1.2
access:  public


[ Top ]

method detach [line 978]

boolean detach( object HTTP_Request_Listener &$listener)

Removes a Listener from the list of listeners



Tags:

return:  whether the listener was successfully detached
access:  public


Parameters:

object HTTP_Request_Listener   &$listener   instance to detach

[ Top ]

method disconnect [line 759]

void disconnect( )

Disconnect the socket, if connected. Only useful if using Keep-Alive.



Tags:

access:  public


[ Top ]

method getResponseBody [line 802]

mixed getResponseBody( )

Returns the body of the response



Tags:

return:  response body, false if not set
access:  public


[ Top ]

method getResponseCode [line 773]

mixed getResponseCode( )

Returns the response code



Tags:

return:  Response code, false if not set
access:  public


[ Top ]

method getResponseCookies [line 813]

mixed getResponseCookies( )

Returns cookies set in response



Tags:

return:  array of response cookies, false if none are present
access:  public


[ Top ]

method getResponseHeader [line 786]

mixed getResponseHeader( [string $headername = null])

Returns either the named header or all if no name given



Tags:

return:  either the value of $headername (false if header is not present) or an array of all headers
access:  public


Parameters:

string   $headername   The header name to return, do not set to get all headers

[ Top ]

method getUrl [line 363]

string getUrl( $url)

Returns the current request URL



Tags:

return:  Current request URL
access:  public


Parameters:

   $url  

[ Top ]

method removeHeader [line 443]

void removeHeader( string $name)

Removes a request header



Tags:

access:  public


Parameters:

string   $name   Header name to remove

[ Top ]

method reset [line 328]

void reset( string $url, [array $params = array()])

Resets the object to its initial state (DEPRECATED).

Takes the same parameters as the constructor.




Tags:

deprecated:  deprecated since 1.2, call the constructor if this is necessary
access:  public


Parameters:

string   $url   The url to be requested
array   $params   Associative array of parameters (see constructor for details)

[ Top ]

method sendRequest [line 615]

mixed sendRequest( [bool $saveBody = true])

Sends the request



Tags:

return:  PEAR error on error, true otherwise
access:  public


Parameters:

bool   $saveBody   Whether to store response body in Response object property, set this to false if downloading a LARGE file and using a Listener

[ Top ]

method setBasicAuth [line 395]

void setBasicAuth( string $user, string $pass)

Sets basic authentication parameters



Parameters:

string   $user   Username
string   $pass   Password

[ Top ]

method setBody [line 563]

void setBody( string $body)

Sets the request body (for POST, PUT and similar requests)



Tags:

access:  public


Parameters:

string   $body   Request body

[ Top ]

method setHttpVer [line 420]

void setHttpVer( string $http)

Sets the HTTP version to use, 1.0 or 1.1



Tags:

access:  public


Parameters:

string   $http   Version to use. Use the defined constants for this

[ Top ]

method setMethod [line 409]

void setMethod( string $method)

Sets the method to be used, GET, POST etc.



Tags:

access:  public


Parameters:

string   $method   Method to use. Use the defined constants for this

[ Top ]

method setProxy [line 377]

void setProxy( string $host, [int $port = 8080], [string $user = null], [string $pass = null])

Sets a proxy to be used



Tags:

access:  public


Parameters:

string   $host   Proxy host
int   $port   Proxy port
string   $user   Proxy username
string   $pass   Proxy password

[ Top ]

method setURL [line 339]

void setURL( string $url)

Sets the URL to be requested



Tags:

access:  public


Parameters:

string   $url   The url to be requested

[ Top ]

method _flattenArray [line 932]

array _flattenArray( string $name, mixed $values)

Helper function to change the (probably multidimensional) associative array into the simple one.



Tags:

return:  array with the following items: array('item name', 'item value');


Parameters:

string   $name   name for item
mixed   $values   item's values

[ Top ]


Documentation generated on Sun, 08 Jan 2012 17:51:58 +0100 by phpDocumentor 1.4.3