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:
Located in Program_Root/HTTP_Message.php (line 42)
| Class | Description |
|---|---|
| HTTP_Request | HTTP Request class |
| HTTP_Response | HTTP Response class |
Headers - HTTP headers object
Constructor.
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);
As string - returns message as string (to be overidden in subclass)
Clone - return a copy (to be overidden in subclass)
Get body (returns reference)
Example:
1 $body =& $msg->get_body();
Get headers (returns reference)
Example:
1 $headers =& $msg->get_headers();
2
Get header array
Returns the header value(s) as an array
specifies maximum number of headers to return (null = no limit (default))
Get header string
Returns the header value, seperated by ', ' if there's more than one.
specifies maximum number of headers to return (null = no limit (default))
Get protocol
Example:
1 $protocol = $msg->get_protocol();
Has body
Example:
1 if ($msg->has_body()) {
2 $body =& $msg->get_body();
3 }
Init header
Set the specified header to the given value, but only if no previous value for that field is set.
array holding values, or string holding a single value
Push header
Add a new field value for the specified header field.
array holding values, or string holding a single value
Remove header
Removes the header fields with the specified name(s).
string to specify a single field, array to specify more than 1 field
Set body
Example:
1 $body = '<html><head><title>Hello</title></head><body>Hello</body></html>';
2 $msg->set_body($body);
Set header
Adds value(s) to header overwriting any existing values.
array holding values, or string holding a single value
Set protocol
Example:
1 $msg->set_protocol('HTTP/1.1');
Documention generated on Wed, 16 Jul 2003 01:03:26 +0100 by phpDocumentor 1.2.0