Class HTTP_Response

Description

HTTP Response class

Use to hold HTTP responses (status line, headers, and message body).

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

Example:


1 $request =& new HTTP_Response(200, 'OK');

TODO:

  • get_current_age() method (RFC 2616 Section 13.2.3)
  • get_freshness_lifetime() method (RFC 2616 Section 13.2.4)
  • is_fresh()

Located in Program_Root/HTTP_Response.php (line 46)

HTTP_Message
   |
   --HTTP_Response
Method Summary
void HTTP_Response ([int $status_code = null], [string $reason_phrase = null], [object $headers = null], [string $body = null])
string as_string ()
object &clone ()
string error_as_html ()
object instance &get_base ()
object false &get_previous ()
string get_reason_phrase ()
object &get_request ()
string get_status_line ()
bool is_client_error ()
bool is_error ()
bool is_info ()
bool is_redirect ()
bool is_server_error ()
bool is_success ()
void set_previous (object &$previous)
void set_reason_phrase (string $reason_phrase)
void set_request (object &$request)
void set_status_code (int $status_code)
Variables

Inherited Variables

Inherited from HTTP_Message

HTTP_Message::$headers
Methods
Constructor HTTP_Response (line 88)

Constructor

Example:


1 $response =& new HTTP_Response(200, 'OK');

void HTTP_Response ([int $status_code = null], [string $reason_phrase = null], [object $headers = null], [string $body = null])
  • int $status_code
  • string $reason_phrase
  • object $headers:

    headers object

  • string $body:

    message body

as_string (line 356)

As string - returns HTTP response message as a string.

string as_string ()

Redefinition of:
HTTP_Message::as_string()
As string - returns message as string (to be overidden in subclass)
clone (line 102)

Clone

Returns a copy. The previous response (if set) will not be copied.

object &clone ()

Redefinition of:
HTTP_Message::clone()
Clone - return a copy (to be overidden in subclass)
error_as_html (line 338)

Error as HTML - Use only when is_error() is true.

string error_as_html ()
get_base (line 245)

Get Base URL

Returns a URL object, the base URL is taken from one of the following 3 headers:

 Content-Base     - HTTP/1.1 RFC 2068 (old spec)
                    RFC 2616 says "Content-Base was deleted from the specification:
                    it was not implemented widely, and there is no simple, safe way to
                    introduce it without a robust extension mechanism."
 Content-Location - HTTP/1.1 RFC 2616
 Base             - RFC 1808 Section 3.1
 

If neither of these headers contain a value, the request URL will be used. If the value found in these headers is a relative URL, it will be set as relative to the request URL.

  • return:

    of the URL class

  • see: URL
object instance &get_base ()
get_previous (line 199)

Get previous response object (returns reference)

Example:


1 $prev_response =& $response->get_previous();

  • return:

    if no previous response available

object false &get_previous ()
get_reason_phrase (line 151)

Get reason phrase

string get_reason_phrase ()
get_request (line 175)

Get request object (returns reference)

Example:


1 $request =& $response->get_request();

object &get_request ()
get_status_code (line 132)

Get status code

int get_status_code ()
get_status_line (line 211)

Get status line

Returns status line as defined in RFC 2616 Section 6.1: Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

string get_status_line ()
is_client_error (line 317)

Is client error

This class of status code is intended for cases in which the client seems to have erred.

bool is_client_error ()
is_error (line 305)

Is error

Returns true for both client or server error status codes.

bool is_error ()
is_info (line 273)

Is info

This class of status code indicates a provisional response which can't have any content.

bool is_info ()
is_redirect (line 294)

Is redirect

This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.

bool is_redirect ()
is_server_error (line 329)

Is server error

This class of status codes is intended for cases in which the server is aware that it has erred or is incapable of performing the request.

bool is_server_error ()
is_success (line 282)

Is success

bool is_success ()
set_previous (line 185)

Set previous response object reference

void set_previous (object &$previous)
  • object $previous:

    passed by reference

set_reason_phrase (line 142)

Set reason phrase

void set_reason_phrase (string $reason_phrase)
  • string $reason_phrase
set_request (line 161)

Set request object reference

void set_request (object &$request)
  • object $request:

    passed by reference

set_status_code (line 123)

Set status code

void set_status_code (int $status_code)
  • int $status_code

Inherited Methods

Inherited From HTTP_Message

HTTP_Message::HTTP_Message()
HTTP_Message::append_body()
HTTP_Message::as_string()
HTTP_Message::clone()
HTTP_Message::get_body()
HTTP_Message::get_body_ref()
HTTP_Message::get_headers()
HTTP_Message::get_headers_ref()
HTTP_Message::get_header_array()
HTTP_Message::get_header_string()
HTTP_Message::get_protocol()
HTTP_Message::has_body()
HTTP_Message::init_header()
HTTP_Message::push_header()
HTTP_Message::remove_header()
HTTP_Message::set_body()
HTTP_Message::set_header()
HTTP_Message::set_headers()
HTTP_Message::set_protocol()

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