From a84e2e5f8fa39386883754b6ab8bcd7fbfb5ed94 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 6 Jun 2005 11:48:46 +0000 Subject: [PATCH] - update docs --- docs/functions.html | 104 +++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/docs/functions.html b/docs/functions.html index 4c6ff04..a1f9024 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -71,9 +71,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';
?>
+



@@ -87,9 +87,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');
}
?>
+



@@ -131,9 +131,9 @@ a "304 Not Modified" status code is issued.

void http_throttle(double sec[, long bytes = 2097152])

Use with http_send() API.

-Example:


-<?php
// ~ 20 kbyte/s
# http_throttle(1, 20000);
# http_throttle(0.5, 10000);
# http_throttle(0.1, 2000);
http_send_file('document.pdf');
?>
-

+Example:


+<?php
// ~ 20 kbyte/s
# http_throttle(1, 20000);
# http_throttle(0.5, 10000);
# http_throttle(0.1, 2000);
http_send_file('document.pdf');
?>
+



@@ -160,16 +160,18 @@ 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(
        
'Response 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(
        
'Response Status' => '200 Ok',
        
'Content-Type' => 'text/plain',
        
'Content-Language' => 'en-US'
    
),
    
1 => "Hello World!"
);
?>
+



array http_parse_headers(string header)

array http_get_request_headers(void)

-

+

Get a list of incoming HTTP headers.

+

bool http_match_request_header(string header, string value[, bool match_case = false])

+

Match an incoming HTTP header.

string http_get(string url[, array options[, array &info]])

Performs an HTTP GET request on the supplied url.

@@ -203,9 +205,9 @@ array where the following keys will be recognized:

 - redirect:
  - connecttimeout:   int, seconds the connect may take
- onprogress: mixed, progress callback
- ondebug: mixed, debug callback

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,
)
?>
+



@@ -222,30 +224,32 @@ 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.

string http_put_file(string url, string file[, array options[, array &info]])

-

+

Performs an HTTP PUT request, uploading file.
+Returns the HTTP response as string.
+See http_get() for a full list of available options.

string http_put_stream(string url, resource stream[, array options[, array &info]])

-

-

bool http_request()

-

}}} */
-
-/* {{{ proto long http_request_method_register(string method)

+

Performs an HTTP PUT request, uploading stream.
+Returns the HTTP response as string.
+See http_get() for a full list of available options.

+

long http_request_method_register(string method)

+

Register a custom request method.

bool http_request_method_unregister(mixed method)

-

+

Unregister a previously registered custom request method.

long http_request_method_exists(mixed method)

-

+

Check if a request method is registered (or available by default).

string http_request_method_name(long method)

-

+

Get the literal string representation of a standard or registered request method.

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



@@ -318,20 +322,20 @@ Will return an associative array like:

array(

Set the file to be sent.

string HttpResponse::getFile()

Get the previously set file to be sent.

-

bool HttpResponse::send()

+

bool HttpResponse::send([bool clean_ob = true])

Finally send the entity.

-Example:


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

+Example:


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



-

static HttpMessage HttpMessage::fromString(string raw_message)

-

Create an HttpMessage object from a string.

HttpMessage

void HttpMessage::__construct([string message])

Instantiate a new HttpMessage object.

+

static HttpMessage HttpMessage::fromString(string raw_message)

+

Create an HttpMessage object from a string.

string HttpMessage::getBody()

Get the body of the parsed Message.

array HttpMessage::getHeaders()

@@ -444,11 +448,23 @@ Affects only POST requests.

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

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

+

bool HttpRequest::setPostFiles()

+

Set files to post.
+Overwrites previously set post files.
+Affects only POST requests.

array HttpRequest::getPostFiles()

Get all previously added POST files.

void HttpRequest::unsetPostFiles()

Unset the POST files list.
Affects only POST requests.

+

bool HttpRequest::SetPutFile(string file)

+

Set file to put.
+Affects only PUT requests.

+

string HttpRequest::getPutFile()

+

Get previously set put file.

+

void HttpRequest::unsetPutFile()

+

Unset file to put.
+Affects only PUT requests.

array HttpRequest::getResponseData()

Get all response data after the request has been sent.

mixed HttpRequest::getResponseHeader([string name])

@@ -467,17 +483,17 @@ See http_get() for a full list of returned info.

bool HttpRequest::send()

Send the HTTP request.

-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;
}
?>
-

-

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');
if (
$r->send()) {
    echo
$r->getResponseBody();
}
?>
-

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

+

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');
if (
$r->send()) {
    echo
$r->getResponseBody();
}
?>
+




-

Generated at: Wed, 25 May 2005 19:01:02 +0200

+

Generated at: Mon, 6 Jun 2005 13:44:11 +0200

-- 2.30.2