From 0f08208cc1b223ccb90554718181d553156997f4 Mon Sep 17 00:00:00 2001
From: Michael Wallner
Generates a form-encoded query string from an associative array or object.
Instantiates a new HTTPi_Response object, which can be used to send
+
Instantiates a new HttpResponse object, which can be used to send
any data/resource/file to an HTTP client with caching and multiple
ranges/resuming support.
NOTE: GZIPping is not implemented yet.
Whether it sould be attempted to cache the entitity.
This will result in necessary caching headers and checks of clients
"If-Modified-Since" and "If-None-Match" headers. If one of those headers
@@ -240,137 +237,143 @@ matches a "304 Not Modified" status code will be issued.
NOTE: If you're using sessions, be shure that you set session.cache_limiter
to something more appropriate than "no-cache"!
Get current caching setting.
-Enable on-thy-fly gzipping of the sent entity. NOT IMPLEMENTED YET.
-Get current gzipping setting.
-Set a custom cache-control header, usually being "private" or "public"; if
$raw is set to true the header will be sent as-is.
Get current Cache-Control header setting.
-Set the content-type of the sent entity.
-Get current Content-Type header setting.
-Set the Content-Disposition of the sent entity. This setting aims to suggest
the receiveing user agent how to handle the sent entity; usually the client
will show the user a "Save As..." popup.
Get current Content-Disposition setting.
Will return an associative array like:
array(-
'filename' => 'foo.bar',
'inline' => false
)
Set a custom ETag. Use this only if you know what you're doing.
-Get the previously set custom ETag.
-Set the data to be sent.
-Get the previously set data to be sent.
-Set the resource to be sent.
-Get the previously set resource to be sent.
-Set the file to be sent.
-Get the previously set file to be sent.
-Finally send the entity.
Example:
-
-<?php
$r = new HTTPi_Response(true);
$r->setFile('../hidden/contract.pdf');
$r->setContentType('application/pdf');
$r->send();
?>
+<?php
$r = new HttpResponse(true);
$r->setFile('../hidden/contract.pdf');
$r->setContentType('application/pdf');
$r->send();
?>
Instantiate a new HTTPi_Request object which can be used to issue HEAD, GET
+
Instantiate a new HttpRequest object which can be used to issue HEAD, GET
and POST (including posting files) HTTP requests.
Destroys the HTTPi_Request object.
-Destroys the HttpRequest object.
+Set the request options to use. See http_get() for a full list of available options.
-Get current set options.
-Unset all options/headers/cookies.
+Add (a) request header name/value pair(s).
+Add (a) cookie(s).
+Set the request URL.
-Get the previously set request URL.
-Set the request methods; one of the HTTP_HEAD, HTTP_GET or
HTTP_POST constants.
Get the previously set request method.
-Set the content type the post request should have.
Use this only if you know what you're doing.
Get the previously content type.
-Set the URL query parameters to use.
Overwrites previously set query parameters.
Affects any request types.
Get the current query data in form of an urlencoded query string.
-Add parameters to the query parameter list.
Affects any request type.
Clean the query parameters.
Affects any request type.
Adds POST data entries.
Affects only POST requests.
Set the POST data entries.
Overwrites previously set POST data.
Affects only POST requests.
Get previously set POST data.
-Clean POST data entires.
Affects only POST requests.
Add a file to the POST request.
Affects only POST requests.
Get all previously added POST files.
-Unset the POST files list.
Affects only POST requests.
Get all response data after the request has been sent.
-Get response header(s) after the request has been sent.
-Get the response body after the request has been sent.
-Get the response code after the request has been sent.
-Get response info after the request has been sent.
See http_get() for a full list of returned info.
Send the HTTP request.
GET example:
-<?php
$r = new HTTPi_Request('http://example.com/feed.rss', HTTP_GET);
$r->setOptions(array('lastmodified' => filemtime('local.rss')));
$r->addQueryData(array('category' => 3));
if ($r->send() && $r->getResponseCode() == 200) {
file_put_contents('local.rss', $r->getResponseBody());
}
?>
+<?php
$r = new HttpRequest('http://example.com/feed.rss', HTTP_GET);
$r->setOptions(array('lastmodified' => filemtime('local.rss')));
$r->addQueryData(array('category' => 3));
if ($r->send() && $r->getResponseCode() == 200) {
file_put_contents('local.rss', $r->getResponseBody());
}
?>
POST example:
-<?php
$r = new HTTPi_Request('http://example.com/form.php', HTTP_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostData(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
if ($r->send()) {
echo $r->getResponseBody();
}
?>
+<?php
$r = new HttpRequest('http://example.com/form.php', HTTP_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostData(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
if ($r->send()) {
echo $r->getResponseBody();
}
?>
Generated at: Mon, 7 Mar 2005 14:09:33 +0100
+Generated at: Tue, 22 Mar 2005 15:41:10 +0100
-- 2.30.2