Class Protocol

Description

Protocol class

This class is based on Protocol.pm <http://www.linpro.no/lwp/libwww-perl/lib/LWP/Protocol.pm> from the libwww-perl collection <http://www.linpro.no/lwp/>. (description grabbed from LWP docs)

This class is used a the base class for all protocol implementations.

When creating an instance of this class, using Protocol::create($scheme, $ua), you get an initialised subclass appropriate for that access method. In other words, the Protocol::create() function calls the constructor for one of its subclasses.

All derived Protocol classes need to override the request() method which is used to service a request. The overridden method can make use of the collect() function to collect together chunks of data as it is received.

TODO:

  • none yet

Located in Program_Root/Protocol/Protocol.php (line 61)


	
			
Direct descendents
Class Description
Protocol_HTTP_Base HTTP base class
Protocol_NOGO NOGO class
Variable Summary
string $error_string
string $scheme
object $ua
Method Summary
void Protocol (string $scheme, object &$ua)
object HTTP_Response &collect (mixed $arg, object &$response, mixed $collector)
object &create (string $scheme, object &$ua)
string get_error_string ()
bool has_error ()
string implementor (string $scheme, [string $class = null])
bool is_error_parse ()
bool is_error_read ()
bool is_error_write ()
void set_error_number (int $error_number)
void set_error_string (string $error_string)
Variables
int $error_number (line 85)

Error number

string $error_string (line 79)

Error string

string $scheme (line 73)

Scheme

object $ua (line 67)

User Agent object

Methods
Constructor Protocol (line 92)

Constructor

void Protocol (string $scheme, object &$ua)
  • string $scheme
  • object $ua:

    User Agent object (passed by reference)

collect (line 188)

Collect.

Called to collect the content of a response, and process it appropriately into a scalar, file, or by calling a callback. If $arg is null, then the content is stored within the $response. If $arg is an instance of File, then the content is written to this file. If $arg is an instance of Callback (or a subclass), then content is passed to the call() method of the object.

The $collector is either:

  • the whole content (if it's a string), or
  • an instance of Callback (or subclass), the call() method of this class will be called and is reponsible for returning pieces of the content to process. The method signals EOF by returning a an empty sting.
The return value from collect() is the $response object reference.

Note: We will only use the callback or file argument if $response->is_success(). This avoids sendig content data for redirects and authentization responses to the callback which would be confusing.

object HTTP_Response &collect (mixed $arg, object &$response, mixed $collector)
  • mixed $arg
  • object $response:

    (passed by reference)

  • mixed $collector
create (line 107)

Create.

Create an instance of the class implementing the protocol to handle the given scheme. This is the function user agents should use to access protocols.

object &create (string $scheme, object &$ua)
  • string $scheme
  • object $ua
get_error_number (line 289)

Get error number

int get_error_number ()
get_error_string (line 307)

Get error string

string get_error_string ()
has_error (line 316)

Has error

bool has_error ()
implementor (line 123)

Implementor get/set

  • return:

    class name

string implementor (string $scheme, [string $class = null])
  • string $scheme
  • string $class:

    (optional, use to set class against scheme)

is_error_connect (line 325)

Is connection error

bool is_error_connect ()
is_error_parse (line 361)

Is parse error (unrecognised syntax)

bool is_error_parse ()
is_error_read (line 343)

Is read error

bool is_error_read ()
is_error_timeout (line 334)

Is timeout error

bool is_error_timeout ()
is_error_write (line 352)

Is write error

bool is_error_write ()
set_error_number (line 280)

Set error number

void set_error_number (int $error_number)
  • int $error_number:

    new value

set_error_string (line 298)

Set error string

void set_error_string (string $error_string)
  • string $error_string:

    new value

Documention generated on Wed, 16 Jul 2003 01:03:43 +0100 by phpDocumentor 1.2.0