X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=docs%2Ffunctions.html;h=0e53c616ce4ffb26a736e14107fef50907ba24d4;hp=b815071d31a3cf5b33523658f2e578956c086127;hb=ef227f4f7f697c954eef0adb9f9f897148a771ca;hpb=0acbfc76b5a3e4122a6d06d64bd834a810806656
diff --git a/docs/functions.html b/docs/functions.html
index b815071..0e53c61 100644
--- a/docs/functions.html
+++ b/docs/functions.html
@@ -81,7 +81,7 @@ The host will be taken either from the Host HTTP header of the client
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:
@@ -253,7 +253,15 @@ several consecutive HTTP messages.
<?php
$uri = http_build_uri("page.php", "https", NULL, 488);
?>
Expects a string parameter containing HTTP headers.
Returns an array on success, or FALSE on failure.
Example:
++
-<?php
$headers = "content-type: text/html; charset=UTF-8\r\n".
"Server: Funky/1.0\r\n".
"Set-Cookie: foo=bar\r\n".
"Set-Cookie: baz=quux\r\n".
"Folded: works\r\n\ttoo\r\n";
print_r(http_parse_headers($headers));
Array
(
[Content-Type] => text/html; chatset=UTF-8
[Server] => Funky/1.0
[Set-Cookie] => Array
(
[0] => foo=bar
[1] => baz=quux
)
[Folded] => works
too
?>
+<?php
$headers = "content-type: text/html; charset=UTF-8\r\n".
"Server: Funky/1.0\r\n".
"Set-Cookie: foo=bar\r\n".
"Set-Cookie: baz=quux\r\n".
"Folded: works\r\n\ttoo\r\n";
print_r(http_parse_headers($headers));
Array
(
[Content-Type] => text/html; chatset=UTF-8
[Server] => Funky/1.0
[Set-Cookie] => Array
(
[0] => foo=bar
[1] => baz=quux
)
[Folded] => works
too
)
?>
+object http_parse_cookie(string cookie)
+Parses HTTP cookies like sent in a response into a struct.
+Expects a string as parameter containing the value of a Set-Cookie response header.
+Returns an stdClass object with the cookie params as properties on success or FALSE on failure.
+Example:
+<?php
print_r(http_parse_cookie("foo=bar; path=/"));
stdClass Object
(
[name] => foo
[value] => bar
[path] => /
)
?>
array http_get_request_headers(void)
@@ -350,7 +358,7 @@ See http_get() for a full list of available options.Returns the request method name as string on success, or FALSE on failure.
string http_build_query(mixed formdata [, string prefix[, string arg_separator]])
Generates a form-encoded query string from an associative array or object.
-string http_gzencode(string data[, int level = -1])
+string http_gzencode(string data[, int level = -1[, int mtime = 0]])
Compress data with the HTTP compatible GZIP encoding.
Expects the first parameter to be a string which contains the data that
should be encoded. Additionally accepts an optional in paramter specifying
@@ -361,7 +369,7 @@ best compression ratio.Uncompress data compressed with the HTTP compatible GZIP encoding.
Expects a string as parameter containing the compressed data.
Returns the decoded string on success, or NULL on failure.
-string http_deflate(string data[, int level = -1])
+string http_deflate(string data[, int level = -1[, bool zlib_header = false]])
Compress data with the HTTP compatible DEFLATE encoding.
Expects the first parameter to be a string containing the data that should
be encoded. Additionally accepts an optional int parameter specifying the
@@ -372,17 +380,6 @@ compression ratio.Uncompress data compressed with the HTTP compatible DEFLATE encoding.
Expects a string as parameter containing the compressed data.
Returns the decoded string on success, or NULL on failure.
-string http_compress(string data[, int level = -1])
-Compress data with the HTTP compatible COMPRESS encoding.
-Expects the first parameter to be a string containing the data which should
-
-be encoded. Additionally accepts an optional int parameter specifying the
-compression level, where -1 is default, 0 is no compression and 9 is best
-compression ratio.Returns the encoded string on success, or NULL on failure.
-string http_uncompress(string data)
-Uncompress data compressed with the HTTP compatible COMPRESS encoding.
-Expects a string as parameter containing the compressed data.
-Returns the decoded string on success, or NULL on failure.
int http_support([int feature = 0])
Check for feature that require external libraries.
Accpepts an optional in parameter specifying which feature to probe for.
@@ -569,7 +566,7 @@ pairs to add.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 +742,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;
}
?>
@@ -759,10 +756,10 @@ HttpMalformedHeaderException, HttpEncodingException.Instantiate a new HttpRequestPool object. An HttpRequestPool is
able to send several HttpRequests in parallel.WARNING: Don't attach/detach HttpRequest objects to the HttpRequestPool
+object while you're using the implemented Iterator interface.
-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 +785,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:
@@ -1023,6 +1019,8 @@ http.cache_log is set.http_parse_headers +http_parse_cookie + http_get_request_headers http_get_request_body @@ -1059,10 +1057,6 @@ http.cache_log is set. http_inflate -http_compress - -http_uncompress - http_support @@ -1201,7 +1195,7 @@ http.cache_log is set. -Generated at: Mon, 21 Nov 2005 16:56:18 +0100
+Generated at: Wed, 14 Dec 2005 16:25:48 +0100