Class HTTP_Message

Description

HTTP Message class

Base class for HTTP messages, use Request and Response subclasses.

This class is based on Message.pm <http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/HTTP/Message.pm> from the libwww-perl collection <http://www.linpro.no/lwp/>.

Example: see HTTP_Request and HTTP_Response subclasses for usage examples.

TODO:

  • none yet

Located in Program_Root/HTTP_Message.php (line 42)


	
			
Direct descendents
Class Description
HTTP_Request HTTP Request class
HTTP_Response HTTP Response class
Variable Summary
object $headers
Method Summary
void HTTP_Message (object &$headers, [string $body = null])
void append_body (string $string)
string as_string ()
object &clone ()
string &get_body ()
string &get_body_ref ()
object &get_headers ()
object reference &get_headers_ref ()
array get_header_array (string $field, [int $limit = null])
string get_header_string (string $field, [int $limit = null])
string get_protocol ()
bool has_body ()
bool init_header (string $field, mixed $value)
void push_header (string $field, mixed $value)
void remove_header (mixed $field)
bool set_body (string $body)
void set_header (string $field, mixed $value)
bool set_headers (object &$headers)
void set_protocol (string $protocol)
Variables
object $headers (line 48)

Headers - HTTP headers object

Methods
Constructor HTTP_Message (line 71)

Constructor.

void HTTP_Message (object &$headers, [string $body = null])
  • object $headers
  • string $body
append_body (line 223)

Append to body - adds content to body

Example:


1 $body_header = '<html><head><title>Test</title></head><body>';
2 $body_footer = '</body></html>';
3 $msg->set_body($body_header);
4 foreach (range(1,10) as $num) {
5 $msg->append_body("Test $num<br />");
6 }
7 $msg->append_body($body_footer);

void append_body (string $string)
  • string $string
as_string (line 233)

As string - returns message as string (to be overidden in subclass)

string as_string ()

Redefined in descendants as:
clone (line 242)

Clone - return a copy (to be overidden in subclass)

object &clone ()

Redefined in descendants as:
get_body (line 191)

Get body (returns reference)

Example:


1 $body =& $msg->get_body();

string &get_body ()
get_body_ref (line 202)

Get body as reference (deprecated)

string &get_body_ref ()
get_headers (line 146)

Get headers (returns reference)

Example:


1 $headers =& $msg->get_headers();
2

object &get_headers ()
get_headers_ref (line 157)

Get headers reference (deprecated)

object reference &get_headers_ref ()
get_header_array (line 314)

Get header array

Returns the header value(s) as an array

array get_header_array (string $field, [int $limit = null])
  • string $field
  • int $limit:

    specifies maximum number of headers to return (null = no limit (default))

get_header_string (line 330)

Get header string

Returns the header value, seperated by ', ' if there's more than one.

string get_header_string (string $field, [int $limit = null])
  • string $field
  • int $limit:

    specifies maximum number of headers to return (null = no limit (default))

get_protocol (line 131)

Get protocol

Example:


1 $protocol = $msg->get_protocol();

  • return:

    false if protocol not set

string get_protocol ()
has_body (line 88)

Has body

Example:


1 if ($msg->has_body()) {
2 $body =& $msg->get_body();
3 }

bool has_body ()
init_header (line 273)

Init header

Set the specified header to the given value, but only if no previous value for that field is set.

bool init_header (string $field, mixed $value)
  • string $field
  • mixed $value:

    array holding values, or string holding a single value

push_header (line 286)

Push header

Add a new field value for the specified header field.

void push_header (string $field, mixed $value)
  • string $field
  • mixed $value:

    array holding values, or string holding a single value

remove_header (line 258)

Remove header

Removes the header fields with the specified name(s).

void remove_header (mixed $field)
  • mixed $field:

    string to specify a single field, array to specify more than 1 field

set_body (line 173)

Set body

Example:


1 $body = '<html><head><title>Hello</title></head><body>Hello</body></html>';
2 $msg->set_body($body);

bool set_body (string $body)
  • string $body
set_header (line 299)

Set header

Adds value(s) to header overwriting any existing values.

void set_header (string $field, mixed $value)
  • string $field
  • mixed $value:

    array holding values, or string holding a single value

set_headers (line 98)

Set headers

bool set_headers (object &$headers)
  • object $headers
set_protocol (line 117)

Set protocol

Example:


1 $msg->set_protocol('HTTP/1.1');

void set_protocol (string $protocol)
  • string $protocol

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