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

Class: HTTP_Client

Source Location: /HTTP_Client-1.0.0/Client.php

Class Overview


A simple HTTP client class.


Author(s):

Version:

  • $Revision: 1.4 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 34]
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.4 $


[ Top ]


Method Detail

HTTP_Client (Constructor)   [line 97]

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

Constructor
  • Access: public

Parameters:

array   $defaultRequestParams   —  Parameters to pass to HTTP_Request's constructor
array   $defaultHeaders   —  Default headers to send on every request

[ Top ]

attach   [line 384]

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

array &currentResponse( )

Returns the most recent HTTP response
  • Access: public

[ Top ]

detach   [line 402]

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

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

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

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

[ Top ]

head   [line 169]

integer head( string $url)

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

Parameters:

string   $url   —  URL

[ Top ]

post   [line 212]

integer post( string $url, mixed $data, [boolean $preEncoded = false], [array $files = 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()

[ Top ]

reset   [line 365]

void reset( )

Clears object's internal properties
  • Access: public

[ Top ]

setDefaultHeader   [line 239]

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

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

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