From 1fd7e6ceece2684e11cf9533e22dfb12a1b80f0e Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 7 Mar 2005 13:10:09 +0000 Subject: [PATCH] * docs --- docs/functions.html | 198 +++++++++++++++++++++++++++++--------------- funcsummary.php | 7 +- 2 files changed, 135 insertions(+), 70 deletions(-) diff --git a/docs/functions.html b/docs/functions.html index 41cf906..2b0af4c 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -1,3 +1,6 @@ +Content-type: text/html +X-Powered-By: PHP/5.0.1 + Function Summary of ext/http @@ -30,6 +33,9 @@ width: auto; float: left; } + p, pre { + clear: both; + } p br, pre code br { display: block; } @@ -39,7 +45,7 @@

string http_date([int timestamp])

This function returns a valid HTTP date regarding RFC 822/1123
looking like: "Wed, 22 Dec 2004 11:34:47 GMT"

-

string http_absolute_uri(string url[, string proto])

+

string http_absolute_uri(string url[, string proto[, string host[, int port]]])

This function returns an absolute URI constructed from url.
If the url is already abolute but a different proto was supplied,
only the proto part of the URI will be updated. If url has no
@@ -61,9 +67,9 @@ The qualifier is recognized and languages without qualifier are rated highest. the supported languages as array values.

-Example:


-<?php
$langs
= array(
        
'en-US',// default
        
'fr',
        
'fr-FR',
        
'de',
        
'de-DE',
        
'de-AT',
        
'de-CH',
);
include
'./langs/'. http_negotiate_language($langs) .'.php';
?>
-

+Example:


+<?php
$langs
= array(
        
'en-US',// default
        
'fr',
        
'fr-FR',
        
'de',
        
'de-DE',
        
'de-AT',
        
'de-CH',
);
include
'./langs/'. http_negotiate_language($langs) .'.php';
?>
+



@@ -77,9 +83,9 @@ The qualifier is recognized and charset without qualifier are rated highest.
the supported charsets as array values.

-Example:


-<?php
$charsets
= array(
        
'iso-8859-1', // default
        
'iso-8859-2',
        
'iso-8859-15',
        
'utf-8'
);
$pref = http_negotiate_charset($charsets);
if (!
strcmp($pref, 'iso-8859-1')) {
        
iconv_set_encoding('internal_encoding', 'iso-8859-1');
        
iconv_set_encoding('output_encoding', $pref);
        
ob_start('ob_iconv_handler');
}
?>
-

+Example:


+<?php
$charsets
= array(
        
'iso-8859-1', // default
        
'iso-8859-2',
        
'iso-8859-15',
        
'utf-8'
);
$pref = http_negotiate_charset($charsets);
if (!
strcmp($pref, 'iso-8859-1')) {
        
iconv_set_encoding('internal_encoding', 'iso-8859-1');
        
iconv_set_encoding('output_encoding', $pref);
        
ob_start('ob_iconv_handler');
}
?>
+



@@ -143,9 +149,9 @@ if the client doesn't redirect immediatly.

Returns false on failure.

array http_split_response(string http_response)

This function splits an HTTP response into an array with headers and the
-content body. The returned array may look simliar to the following example:


-<?php
array(
    
0 => array(
        
'Status' => '200 Ok',
        
'Content-Type' => 'text/plain',

        
'Content-Language' => 'en-US'
    
),
    
1 => "Hello World!"
);
?>
-

+content body. The returned array may look simliar to the following example:


+<?php
array(
    
0 => array(
        
'Status' => '200 Ok',
        
'Content-Type' => 'text/plain',

        
'Content-Language' => 'en-US'
    
),
    
1 => "Hello World!"
);
?>
+



@@ -184,9 +190,9 @@ array where the following keys will be recognized:

 - redirect:
  - lastmodified:     int, timestamp for If-(Un)Modified-Since header
- timeout: int, seconds the request may take
- connecttimeout: int, seconds the connect may take

The optional third parameter will be filled with some additional information
-in form af an associative array, if supplied, like the following example:


-<?php
array (
    
'effective_url' => 'http://localhost',
    
'response_code' => 403,
    
'total_time' => 0.017,
    
'namelookup_time' => 0.013,
    
'connect_time' => 0.014,
    
'pretransfer_time' => 0.014,
    
'size_upload' => 0,
    
'size_download' => 202,
    
'speed_download' => 11882,
    
'speed_upload' => 0,
    
'header_size' => 145,
    
'request_size' => 62,
    
'ssl_verifyresult' => 0,
    
'filetime' => -1,
    
'content_length_download' => 202,
    
'content_length_upload' => 0,
    
'starttransfer_time' => 0.017,
    
'content_type' => 'text/html; charset=iso-8859-1',
    
'redirect_time' => 0,
    
'redirect_count' => 0,
    
'private' => '',
    
'http_connectcode' => 0,
    
'httpauth_avail' => 0,
    
'proxyauth_avail' => 0,
)
?>
-

+in form af an associative array, if supplied, like the following example:


+<?php
array (
    
'effective_url' => 'http://localhost',
    
'response_code' => 403,
    
'total_time' => 0.017,
    
'namelookup_time' => 0.013,
    
'connect_time' => 0.014,
    
'pretransfer_time' => 0.014,
    
'size_upload' => 0,
    
'size_download' => 202,
    
'speed_download' => 11882,
    
'speed_upload' => 0,
    
'header_size' => 145,
    
'request_size' => 62,
    
'ssl_verifyresult' => 0,
    
'filetime' => -1,
    
'content_length_download' => 202,
    
'content_length_upload' => 0,
    
'starttransfer_time' => 0.017,
    
'content_type' => 'text/html; charset=iso-8859-1',
    
'redirect_time' => 0,
    
'redirect_count' => 0,
    
'private' => '',
    
'http_connectcode' => 0,
    
'httpauth_avail' => 0,
    
'proxyauth_avail' => 0,
)
?>
+



@@ -203,16 +209,16 @@ See http_get() for a full list of available options.

Returns the HTTP response as string.
See http_get() for a full list of available options.

bool http_auth_basic(string user, string pass[, string realm = "Restricted"])

-

Example:


-<?php
if (!http_auth_basic('mike', 's3c|r3t')) {
    die(
'<h1>Authorization failed!</h1>');
}
?>
-

+

Example:


+<?php
if (!http_auth_basic('mike', 's3c|r3t')) {
    die(
'<h1>Authorization failed!</h1>');
}
?>
+



bool http_auth_basic_cb(mixed callback[, string realm = "Restricted"])

-

Example:


-<?php
function auth_cb($user, $pass)
{
    global
$db;
    
$query = 'SELECT pass FROM users WHERE user='. $db->quoteSmart($user);
    if (
strlen($realpass = $db->getOne($query)) {
        return
$pass === $realpass;
    }
    return
false;
}
if (!
http_auth_basic_cb('auth_cb')) {
    die(
'<h1>Authorization failed</h1>');
}
?>
-

+

Example:


+<?php
function auth_cb($user, $pass)
{
    global
$db;
    
$query = 'SELECT pass FROM users WHERE user='. $db->quoteSmart($user);
    if (
strlen($realpass = $db->getOne($query)) {
        return
$pass === $realpass;
    }
    return
false;
}
if (!
http_auth_basic_cb('auth_cb')) {
    die(
'<h1>Authorization failed</h1>');
}
?>
+



@@ -221,96 +227,150 @@ See http_get() for a full list of available options.


http_methods.c

void HTTPi_Response::__construct(bool cache, bool gzip)

-

+

Instantiates a new HTTPi_Response 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.

bool HTTPi_Response::setCache(bool cache)

-

+

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
+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"!

bool HTTPi_Response::getCache()

-

+

Get current caching setting.

bool HTTPi_Response::setGzip(bool gzip)

-

+

Enable on-thy-fly gzipping of the sent entity. NOT IMPLEMENTED YET.

bool HTTPi_Response::getGzip()

-

+

Get current gzipping setting.

bool HTTPi_Response::setCacheControl(string control[, bool raw = false])

-

+

Set a custom cache-control header, usually being "private" or "public"; if
+$raw is set to true the header will be sent as-is.

string HTTPi_Response::getCacheControl()

-

-

bool HTTPi::setContentType(string content_type)

-

+

Get current Cache-Control header setting.

+

bool HTTPi_Response::setContentType(string content_type)

+

Set the content-type of the sent entity.

string HTTPi_Response::getContentType()

-

+

Get current Content-Type header setting.

bool HTTPi_Response::setContentDisposition(string filename[, bool inline = false])

-

+

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.

array HTTPi_Response::getContentDisposition()

-

+

Get current Content-Disposition setting.
+Will return an associative array like:

array(
+ 'filename' => 'foo.bar',
+ 'inline' => false
+)
+

bool HTTPi_Response::setETag(string etag)

-

+

Set a custom ETag. Use this only if you know what you're doing.

string HTTPi_Response::getETag()

-

+

Get the previously set custom ETag.

bool HTTPi_Response::setData(string data)

-

+

Set the data to be sent.

string HTTPi_Response::getData()

-

+

Get the previously set data to be sent.

bool HTTPi_Response::setStream(resource stream)

-

+

Set the resource to be sent.

resource HTTPi_Response::getStream()

-

+

Get the previously set resource to be sent.

bool HTTPi_Response::setFile(string file)

-

+

Set the file to be sent.

string HTTPi_Response::getFile()

-

+

Get the previously set file to be sent.

+

bool HTTPi_Response::send()

+

Finally send the entity.
+
+Example:


+<?php
$r
= new HTTPi_Response(true);
$r->setFile('../hidden/contract.pdf');
$r->setContentType('application/pdf');
$r->send();
?>
+

+

+
+

void HTTPi_Request::__construct([string url[, long request_method = HTTP_GET]])

-

+

Instantiate a new HTTPi_Request object which can be used to issue HEAD, GET
+and POST (including posting files) HTTP requests.

void HTTPi_Request::__destruct()

-

+

Destroys the HTTPi_Request object.

bool HTTPi_Request::setOptions(array options)

-

+

Set the request options to use. See http_get() for a full list of available options.

array HTTPi_Request::getOptions()

-

+

Get current set options.

bool HTTPi_Request::setURL(string url)

-

+

Set the request URL.

string HTTPi_Request::getUrl()

-

+

Get the previously set request URL.

bool HTTPi_Request::setMethod(long request_method)

-

+

Set the request methods; one of the HTTP_HEAD, HTTP_GET or
+HTTP_POST constants.

long HTTPi_Request::getMethod()

-

+

Get the previously set request method.

bool HTTPi_Request::setContentType(string content_type)

-

+

Set the content type the post request should have.
+Use this only if you know what you're doing.

string HTTPi_Request::getContentType()

-

+

Get the previously content type.

bool HTTPi_Request::setQueryData(mixed query_data)

-

+

Set the URL query parameters to use.
+Overwrites previously set query parameters.
+Affects any request types.

string HTTPi_Request::getQueryData()

-

+

Get the current query data in form of an urlencoded query string.

bool HTTPi_Request::addQueryData(array query_params)

-

+

Add parameters to the query parameter list.
+Affects any request type.

void HTTPi_Request::unsetQueryData()

-

+

Clean the query parameters.
+Affects any request type.

bool HTTPi_Request::addPostData(array post_data)

-

+

Adds POST data entries.
+Affects only POST requests.

bool HTTPi_Request::setPostData(array post_data)

-

+

Set the POST data entries.
+Overwrites previously set POST data.
+Affects only POST requests.

array HTTPi_Request::getPostData()

-

+

Get previously set POST data.

void HTTPi_Request::unsetPostData()

-

+

Clean POST data entires.
+Affects only POST requests.

bool HTTPi_Request::addPostFile(string name, string file[, string content_type = "application/x-octetstream"])

-

+

Add a file to the POST request.
+Affects only POST requests.

array HTTPi_Request::getPostFiles()

-

+

Get all previously added POST files.

void HTTPi_Request::unsetPostFiles()

-

+

Unset the POST files list.
+Affects only POST requests.

array HTTPi_Request::getResponseData()

-

-

array HTTPi_Request::getResponseHeaders()

-

+

Get all response data after the request has been sent.

+

string HTTPi_Request::getResponseHeader([string name])

+

Get response header(s) after the request has been sent.

string HTTPi_Request::getResponseBody()

-

-

array HTTPi_Request::getResponseInfo()

-

+

Get the response body after the request has been sent.

+

int HTTPi_Request::getResponseCode()

+

Get the response code after the request has been sent.

+

array HTTPi_Request::getResponseInfo([string name])

+

Get response info after the request has been sent.
+See http_get() for a full list of returned info.

bool HTTPi_Request::send()

-

+

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());
}
?>
+

+

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();
}
?>
+

+

+
+


-

Generated at: Fri, 4 Mar 2005 14:10:16 +0100

+

Generated at: Mon, 7 Mar 2005 14:09:33 +0100

- \ No newline at end of file + + diff --git a/funcsummary.php b/funcsummary.php index f8a96cf..b819827 100644 --- a/funcsummary.php +++ b/funcsummary.php @@ -53,6 +53,9 @@ $preface = <<<_PREFACE width: auto; float: left; } + p, pre { + clear: both; + } p br, pre code br { display: block; } @@ -65,6 +68,7 @@ $footer = <<<_FOOTER

Generated at: %s

+ _FOOTER; if ($_SERVER['argc'] < 2) { @@ -85,4 +89,5 @@ foreach (array_slice($_SERVER['argv'], 1) as $f) { } printf($footer, date('r')); -?> \ No newline at end of file +?> + -- 2.30.2