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

Class: HTTP_Client

Source Location: /HTTP_Client-1.1.0/Client.php

Class Overview


A simple HTTP client class.


Author(s):

Version:

  • $Revision: 1.7 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 42]
A simple HTTP client class.

The class wraps around HTTP_Request providing a higher-level API for performing multiple HTTP requests

  • Author: Alexey Borzov <avb@php.net>
  • Version: $Revision: 1.7 $


[ Top ]


Method Detail

HTTP_Client (Constructor)   [line 106]

HTTP_Client HTTP_Client( [array $defaultRequestParams = null], [array $defaultHeaders = null], [object HTTP_Client_CookieManager $cookieManager = null])

Constructor
  • Access: public

Parameters:

array   $defaultRequestParams   —  Parameters to pass to HTTP_Request's constructor
array   $defaultHeaders   —  Default headers to send on every request
object HTTP_Client_CookieManager   $cookieManager   —  Cookie manager object to use

[ Top ]

attach   [line 417]

boolean attach( object HTTP_Request_Listener &$listener, [boolean $propagate = false])

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
boolean   $propagate   —  Whether the listener should be attached to the created HTTP_Request objects

[ Top ]

currentResponse   [line 369]

array &currentResponse( )

Returns the most recent HTTP response
  • Access: public

[ Top ]

detach   [line 435]

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 ]

enableHistory   [line 144]

void enableHistory( bool $enable)

Sets whether to keep all the responses or just the most recent one
  • Access: public

Parameters:

bool   $enable   —  Whether to enable history

[ Top ]

get   [line 205]

integer get( string $url, [mixed $data = null], [boolean $preEncoded = false], [array $headers = array()])

Sends a 'GET' HTTP request
  • Return: HTTP response code
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $url   —  URL
mixed   $data   —  additional data to send
boolean   $preEncoded   —  Whether the data is already urlencoded
array   $headers   —  Extra headers to send

[ Top ]

getCookieManager   [line 507]

object HTTP_Client_CookieManager getCookieManager( )

Returns the cookie manager object (e.g. for storing it somewhere)
  • Access: public

[ Top ]

head   [line 187]

integer head( string $url, [array $headers = array()])

Sends a 'HEAD' HTTP request
  • Return: HTTP response code
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $url   —  URL
array   $headers   —  Extra headers to send

[ Top ]

post   [line 232]

integer post( string $url, mixed $data, [boolean $preEncoded = false], [array $files = array()], [array $headers = array()])

Sends a 'POST' HTTP request
  • Return: HTTP response code
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $url   —  URL
mixed   $data   —  Data to send
boolean   $preEncoded   —  Whether the data is already urlencoded
array   $files   —  Files to upload. Elements of the array should have the form: array(name, filename(s)[, content type]), see HTTP_Request::addFile()
array   $headers   —  Extra headers to send

[ Top ]

reset   [line 398]

void reset( )

Clears object's internal properties
  • Access: public

[ Top ]

setDefaultHeader   [line 259]

void setDefaultHeader( mixed $name, [string $value = null])

Sets default header(s) for HTTP requests
  • Access: public

Parameters:

mixed   $name   —  header name or array ('header name' => 'header value')
string   $value   —  header value if $name is not an array

[ Top ]

setMaxRedirects   [line 132]

void setMaxRedirects( int $value)

Sets the maximum redirects that will be processed.

Setting this to 0 disables redirect processing. If not 0 and the number of redirects in a request is bigger than this number, then an error will be raised.

  • Access: public

Parameters:

int   $value   —  Max number of redirects to process

[ Top ]

setRequestParameter   [line 276]

void setRequestParameter( mixed $name, [string $value = null])

Sets parameter(s) for HTTP requests
  • Access: public

Parameters:

mixed   $name   —  parameter name or array ('parameter name' => 'parameter value')
string   $value   —  parameter value if $name is not an array

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:40:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.