From: Michael Wallner
the SERVER_NAME or just localhost if prior are not available.
If a port is pecified in either the url or as sperate parameter,
it will be added if it differs from te default port for HTTP(S).
Returns the absolute URI as string.
+Returns the absolute URI as string on success or false on failure.
Examples:
@@ -569,7 +569,7 @@ pairs to add.
<?php
$uri = http_build_uri("page.php", "https", NULL, 488);
?>
bool HttpRequest::setMethod(int request_method)
Set the request method.
Expects an int as parameter specifying the request method to use.
+In PHP 5.1+ HttpRequest::METH_*, otherwise the HTTP_METH_* constants can be used.
-In PHP 5.1+ HttpRequest::METH, otherwise the HTTP_METH constants can be used.Returns TRUE on success, or FALSE on failure.
int HttpRequest::getMethod()
Get the previously set request method.
@@ -745,11 +745,11 @@ HttpRequest::getResponse*() methods.Throws HttpRuntimeException, HttpRequestException,
HttpMalformedHeaderException, HttpEncodingException.GET example:
-<?php
$r = new HttpRequest('http://example.com/feed.rss', HTTP_GET);
$r->setOptions(array('lastmodified' => filemtime('local.rss')));
$r->addQueryData(array('category' => 3));
try {
$r->send();
if ($r->getResponseCode() == 200) {
file_put_contents('local.rss', $r->getResponseBody());
}
} catch (HttpException $ex) {
echo $ex;
}
?>
+<?php
$r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET);
$r->setOptions(array('lastmodified' => filemtime('local.rss')));
$r->addQueryData(array('category' => 3));
try {
$r->send();
if ($r->getResponseCode() == 200) {
file_put_contents('local.rss', $r->getResponseBody());
}
} catch (HttpException $ex) {
echo $ex;
}
?>
POST example:
-<?php
$r = new HttpRequest('http://example.com/form.php', HTTP_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
+<?php
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
@@ -762,7 +762,7 @@ able to send several HttpRequests in parallel. object while you're using the implemented Interator interface.Accepts virtual infinite optional parameters each referencing an
-
HttpRequest object.Throws HttpRequestException, HttpRequestPoolException, HttpInvalidParamException.
+Throws HttpRequestPoolException (HttpRequestException, HttpInvalidParamException).
Example:
@@ -788,8 +788,7 @@ HttpRequestPool object.
<?php
try {
$pool = new HttpRequestPool(
new HttpRequest('http://www.google.com/', HttpRequest::METH_HEAD),
new HttpRequest('http://www.php.net/', HttpRequest::METH_HEAD)
);
$pool->send();
foreach($pool as $request) {
printf("%s is %s (%d)\n",
$request->getUrl(),
$request->getResponseCode() ? 'alive' : 'not alive',
$request->getResponseCode()
);
}
} catch (HttpException $e) {
echo $e;
}
?>
bool HttpRequestPool::send()
Send all attached HttpRequest objects in parallel.
Returns TRUE on success, or FALSE on failure.
-Throws HttpSocketException, HttpRequestException,
+
-HttpRequestPoolException, HttpMalformedHeaderException.Throws HttpRequestPoolException (HttpSocketException, HttpRequestException, HttpMalformedHeaderException).
protected bool HttpRequestPool::socketPerform()
Returns TRUE until each request has finished its transaction.
Usage:
@@ -1201,7 +1200,7 @@ http.cache_log is set. -Generated at: Mon, 21 Nov 2005 16:56:18 +0100
+Generated at: Fri, 09 Dec 2005 13:56:42 +0100