Class HTTP_Request

Description

HTTP Request class

Use to hold HTTP requests (request line, headers, and message body).

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

Example:


1 $request =& new HTTP_Request('GET', new URL('http://www.k1m.com/'));

TODO:

  • none yet

Located in Program_Root/HTTP_Request.php (line 45)

HTTP_Message
   |
   --HTTP_Request
Variable Summary
string $method
string $request_uri
object $url
Method Summary
void HTTP_Request (string $method, mixed &$url, object &$headers, [string $body = null])
string as_string ([bool $with_body = true])
array authorization_basic ([string $user = null], [string $pass = ''])
object &clone ()
string content_type ([string $string = null])
string get_method ()
string get_request_uri ()
object &get_url ()
string get_url_string ()
array proxy_authorization_basic ([string $user = null], [string $pass = ''])
string referer ([string $string = null])
void set_method (string $method)
void set_request_uri (string $request_uri)
void set_url (mixed &$url)
string user_agent ([string $string = null])
Variables
string $method (line 51)

Method

string $request_uri (line 63)

Request-URI (used only in Request-Line)

object $url (line 57)

URL - instance of URL class

Inherited Variables

Inherited from HTTP_Message

HTTP_Message::$headers
Methods
Constructor HTTP_Request (line 77)

Constructor

Example:


1 $request =& new HTTP_Request('GET', new URL('http://www.k1m.com/'));

void HTTP_Request (string $method, mixed &$url, object &$headers, [string $body = null])
  • string $method
  • mixed $url:

    either URL string, or URL object

  • object $headers:

    headers object

  • string $body:

    message body

as_string (line 200)

As string

Returns HTTP request message as a string. Accepts 1 argument, this is specify whether the request body should be included in the resulting string, if unspecified, the body will be included. Note: body is only included if it is a string.

This should only be used for debugging, how the actual request will look depends on other factors which the Request object will not be aware of. For example, RFC 2616 (HTTP/1.1) Section 5.1.2 states "The absoluteURI form is REQUIRED when the request is being made to a proxy." The Request object will not know if the request will be passing through a proxy or not, so it's best to build the request message at a time when this information is available.

string as_string ([bool $with_body = true])
  • bool $with_body:

    specify whether to include body or not, if unspecified, body will be included.


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

Authorization: Basic

array authorization_basic ([string $user = null], [string $pass = ''])
  • string $user
  • string $pass
clone (line 221)

Clone - return a copy

object &clone ()

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

Content-Type

string content_type ([string $string = null])
  • string $string
get_method (line 126)

Get method

string get_method ()
get_request_uri (line 107)

Get request-uri.

See note in set_request_uri() to see why this might be used.

string get_request_uri ()
get_url (line 165)

Get URL object

Example:


1 $url =& $request->get_url();

object &get_url ()
get_url_string (line 174)

Get URL string (calls the as_string() method of the URL class)

string get_url_string ()
proxy_authorization_basic (line 296)

Proxy-Authorization: Basic

array proxy_authorization_basic ([string $user = null], [string $pass = ''])
  • string $user
  • string $pass
referer (line 261)

Referer

string referer ([string $string = null])
  • string $string
set_method (line 117)

Set method

void set_method (string $method)
  • string $method
set_request_uri (line 97)

Set request-uri

NOTE: The Request-Line is built differently depending on certain factors. This method allows a complete representation of a request to be held, only useful in situations when the request object is going to be treated as is.

void set_request_uri (string $request_uri)
  • string $request_uri
set_url (line 147)

Set URL

Example:


1 $url = 'http://www.medialens.org';
2 $request->set_url($url);
or

1 $url =& new URL('http://www.medialens.org');
2 $request->set_url($url);

void set_url (mixed &$url)
  • mixed $url:

    string or URL object

user_agent (line 250)

User-Agent

string user_agent ([string $string = null])
  • string $string

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:28 +0100 by phpDocumentor 1.2.0