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

Class: HTTP_Request

Source Location: /HTTP_Request-1.2.3/Request.php

Class Overview




Methods


Inherited Variables

Inherited Methods


Class Details

[line 61]


[ Top ]


Method Detail

HTTP_Request (Constructor)   [line 222]

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

Constructor

Sets up the object

  • Access: public

Parameters:

$url   $url   —  The url to fetch/access
$params   $params   —  Associative array of parameters which can be: method - Method to use, GET, POST etc http - HTTP Version to use, 1.0 or 1.1 user - Basic Auth username pass - Basic Auth password proxy_host - Proxy server host proxy_port - Proxy server port proxy_user - Proxy auth username proxy_pass - Proxy auth password timeout - Connection timeout in seconds. allowRedirects - Whether to follow redirects or not maxRedirects - Max number of redirects to follow useBrackets - Whether to append [] to array variable names saveBody - Whether to save response body in response object property

[ Top ]

addCookie   [line 539]

void addCookie( string $name, string $value)

Appends a cookie to "Cookie:" header
  • Access: public

Parameters:

string   $name   —  cookie name
string   $value   —  cookie value

[ Top ]

addFile   [line 488]

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

  • 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 ]

addHeader   [line 395]

void addHeader( string $name, string $value)

Adds a request header
  • Access: public

Parameters:

string   $name   —  Header name
string   $value   —  Header value

[ Top ]

addPostData   [line 446]

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

Adds postdata items
  • 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 ]

addQueryString   [line 421]

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

Adds a querystring parameter
  • 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 ]

addRawPostData   [line 514]

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

Adds raw postdata
  • Access: public

Parameters:

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

[ Top ]

addRawQueryString   [line 433]

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

Sets the querystring to literally what you supply
  • 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 ]

attach   [line 841]

boolean attach( object HTTP_Request_Listener &$listener)

Adds a Listener to the list of listeners that are notified of the object's events
  • Return: whether the listener was successfully attached
  • Access: public

Parameters:

object HTTP_Request_Listener   &$listener   —  instance to attach

[ Top ]

clearCookies   [line 553]

void clearCookies( )

Clears any cookies that have been added (DEPRECATED).

Useful for multiple request scenarios

  • Deprecated: deprecated since 1.2
  • Access: public

[ Top ]

clearPostData   [line 527]

void clearPostData( )

Clears any postdata that has been added (DEPRECATED).

Useful for multiple request scenarios.

  • Deprecated: deprecated since 1.2
  • Access: public

[ Top ]

detach   [line 858]

boolean detach( object HTTP_Request_Listener &$listener)

Removes a Listener from the list of listeners
  • Return: whether the listener was successfully detached
  • Access: public

Parameters:

object HTTP_Request_Listener   &$listener   —  instance to detach

[ Top ]

getResponseBody   [line 690]

mixed getResponseBody( )

Returns the body of the response
  • Return: response body, false if not set
  • Access: public

[ Top ]

getResponseCode   [line 662]

mixed getResponseCode( )

Returns the response code
  • Return: Response code, false if not set
  • Access: public

[ Top ]

getResponseCookies   [line 701]

mixed getResponseCookies( )

Returns cookies set in response
  • Return: array of response cookies, false if none are present
  • Access: public

[ Top ]

getResponseHeader   [line 675]

mixed getResponseHeader( [string $headername = null])

Returns either the named header or all if no name given
  • 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 ]

removeHeader   [line 406]

void removeHeader( string $name)

Removes a request header
  • Access: public

Parameters:

string   $name   —  Header name to remove

[ Top ]

reset   [line 307]

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

Resets the object to its initial state (DEPRECATED).

Takes the same parameters as the constructor.

  • 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 ]

sendRequest   [line 566]

mixed sendRequest( [bool $saveBody = true])

Sends the request
  • 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 ]

setBasicAuth   [line 358]

void setBasicAuth( string $user, string $pass)

Sets basic authentication parameters

Parameters:

string   $user   —  Username
string   $pass   —  Password

[ Top ]

setHttpVer   [line 383]

void setHttpVer( string $http)

Sets the HTTP version to use, 1.0 or 1.1
  • Access: public

Parameters:

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

[ Top ]

setMethod   [line 372]

void setMethod( string $method)

Sets the method to be used, GET, POST etc.
  • Access: public

Parameters:

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

[ Top ]

setProxy   [line 340]

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

Sets a proxy to be used
  • Access: public

Parameters:

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

[ Top ]

setURL   [line 318]

void setURL( string $url)

Sets the URL to be requested
  • Access: public

Parameters:

string   $url   —  The url to be requested

[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:56:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.