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

Class: HTTP_Request

Source Location: /HTTP_Request-1.3.0/Request.php

Class Overview




Methods


Inherited Variables

Inherited Methods


Class Details

[line 61]


[ Top ]


Method Detail

HTTP_Request (Constructor)   [line 238]

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

Constructor

Sets up the object

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

addCookie   [line 568]

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

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

void addHeader( string $name, string $value)

Adds a request header
  • Access: public

Parameters:

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

[ Top ]

addPostData   [line 463]

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

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

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

Adds raw postdata (DEPRECATED)
  • Deprecated: deprecated since 1.3.0, method addBody() should be used instead
  • Access: public

Parameters:

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

[ Top ]

addRawQueryString   [line 450]

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

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

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

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

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

mixed getResponseBody( )

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

[ Top ]

getResponseCode   [line 698]

mixed getResponseCode( )

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

[ Top ]

getResponseCookies   [line 738]

mixed getResponseCookies( )

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

[ Top ]

getResponseHeader   [line 711]

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

void removeHeader( string $name)

Removes a request header
  • Access: public

Parameters:

string   $name   —  Header name to remove

[ Top ]

reset   [line 324]

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

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

void setBasicAuth( string $user, string $pass)

Sets basic authentication parameters

Parameters:

string   $user   —  Username
string   $pass   —  Password

[ Top ]

setBody   [line 543]

void setBody( string $body)

Sets the request body (for POST, PUT and similar requests)
  • Access: public

Parameters:

string   $body   —  Request body

[ Top ]

setHttpVer   [line 400]

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

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

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

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 14:10:29 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.