X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=docs%2Ffunctions.html;h=02b48406b0cbcfd56f95dc0ab6bb3dd104e4d8f7;hb=5bf21b22dcc28e60dca9dc4637520ee0cb9f565d;hp=880df1014cbd51aeeacb64069c845a85423e0f6e;hpb=1f5a1441ed2a2a655f1bdcbf962c59b6e6c311a8;p=m6w6%2Fext-http diff --git a/docs/functions.html b/docs/functions.html index 880df10..02b4840 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -70,14 +70,41 @@

http_functions.c

string http_date([int timestamp])

-

Compose a valid HTTP date regarding RFC 822/1123
+

Compose a valid HTTP date regarding RFC 1123
looking like: "Wed, 22 Dec 2004 11:34:47 GMT"

Accepts an optional unix timestamp as parameter.

Returns the HTTP date as string.

string http_build_url(mixed url[, mixed parts[, int flags = HTTP_URL_REPLACE[, array &new_url]]])

-

Returns the new URL as string on success or FALSE on failure.

+

Build an URL.

+

Expexts (part(s) of) an URL as first parameter in form of a string or assoziative array
+like parse_url() returns. Accepts an optional second parameter in the same way as the
+first argument. Accepts an optional third integer parameter, which is a bitmask of
+binary or'ed HTTP_URL_* constants. The optional fourth parameter will be filled
+with the results as associative array like parse_url() would return.

+

The parts of the second URL will be merged into the first according to the flags argument.
+The following flags are recognized:

	- HTTP_URL_REPLACE:        (default) set parts of the second url will replace the parts in the first
+ - HTTP_URL_JOIN_PATH: the path of the second url will be merged into the one of the first
+ - HTTP_URL_JOIN_QUERY: the two querystrings will be merged naivly; no replacements are done
+ - HTTP_URL_STRIP_USER: the user part will not appear in the result
+ - HTTP_URL_STRIP_PASS: the password part will not appear in the result
+ - HTTP_URL_STRIP_AUTH: neither the user nor the password part will appear in the result
+ - HTTP_URL_STRIP_PORT: no explicit port will be set in the result
+ - HTTP_URL_STRIP_PATH: the path part will not appear in the result
+ - HTTP_URL_STRIP_QUERY: no query string will be present in the result
+ - HTTP_URL_STRIP_FRAGMENT: no fragment will be present in the result
+

+

Example:


+<?php
        
// ftp://ftp.example.com/pub/files/current/?a=b&a=c
        
echo http_build_url("http://user@www.example.com/pub/index.php?a=b#files",
            array(
                
"scheme" => "ftp",
                
"host"   => "ftp.example.com",
                
"path"   => "files/current/",
                
"query"  => "a=c"
            
),
            
HTTP_URL_STRIP_AUTH HTTP_URL_JOIN_PATH HTTP_URL_JOIN_QUERY HTTP_URL_STRIP_FRAGMENT
        
);
?>
+

+


+Returns the new URL as string on success or FALSE on failure.

string http_build_str(array query [, string prefix[, string arg_separator]])

Opponent to parse_str().

+

Expects an array as first argument which represents the parts of the query string to build.
+Accepts a string as optional second parameter containing a top-level prefix to use.
+The optional third parameter should specify an argument separator to use (by default the
+INI setting arg_separator.output will be used, or "&" if neither is set).

+

Returns the built query as string on success or FALSE on failure.

string http_negotiate_language(array supported[, array &result])

This function negotiates the clients preferred language based on its
Accept-Language HTTP header. The qualifier is recognized and languages
@@ -249,12 +276,12 @@ several consecutive HTTP messages.

<?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/htmlchatset=UTF-8
    
[Server] => Funky/1.0
    
[Set-Cookie] => Array
        (
            [
0] => foo=bar
            
[1] => baz=quux
        
)
    [
Folded] => works
        too 

?>

- +

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.

+

Returns an stdClass olike shown in the example on success or FALSE on failure.

Example:


-<?php
print_r
(http_parse_cookie("foo=bar; path=/"));

stdClass Object
(
    [
name] => foo
    
[value] => bar
    
[path] => /
)
?>
+<?php
print_r
(http_parse_cookie("foo=bar; bar=baz; path=/; domain=example.com; comment=; secure"0, array("comment")));

stdClass Object
(
    [
cookies] => Array
        (
            [
foo] => bar
            
[bar] => baz
        
)

    [
extras] => Array
        (
            [
comment] =>
        )

    [
flags] => 16
    
[expires] => 0
    
[path] => /
    [
domain] => example.com
)
?>

array http_get_request_headers(void)

@@ -296,7 +323,10 @@ array where the following keys will be recognized:

 - redirect:
                      like array("header" => "value")
- cookies: array, list of cookies as associative array
like array("cookie" => "value")
+ - encodecookies: bool, whether to urlencode the cookies (default: true)
+ - resetcookies: bool, wheter to reset the cookies
- cookiestore: string, path to a file where cookies are/will be stored
+ - cookiesession: bool, accept (true) or reset (false) sessioncookies
- resume: int, byte offset to start the download from;
if the server supports ranges
- maxfilesize: int, maximum file size that should be downloaded;
@@ -306,6 +336,8 @@ array where the following keys will be recognized:

 - redirect:
  - timeout:          int, seconds the request may take
- connecttimeout: int, seconds the connect may take
- onprogress: mixed, progress callback
+ - interface: string, outgoing network interface (ifname, ip or hostname)
+ - portrange: array, 2 integers specifying outgoing portrange to try
- ssl: array, with the following options:
cert: string, path to certificate
certtype: string, type of certificate
@@ -325,7 +357,7 @@ array where the following keys will be recognized:

 - redirect:
 

The optional third parameter will be filled with some additional information
in form of 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,
    
'http_connectcode' => 0,
    
'httpauth_avail' => 0,
    
'proxyauth_avail' => 0,
)
?>
+<?php
array (
   
'effective_url' => 'http://www.example.com/',
   
'response_code' => 302,
   
'connect_code' => 0,
   
'filetime' => -1,
   
'total_time' => 0.212348,
   
'namelookup_time' => 0.038296,
   
'connect_time' => 0.104144,
   
'pretransfer_time' => 0.104307,
   
'starttransfer_time' => 0.212077,
   
'redirect_time' => 0,
   
'redirect_count' => 0,
   
'size_upload' => 0,
   
'size_download' => 218,
   
'speed_download' => 1026,
   
'speed_upload' => 0,
   
'header_size' => 307,
   
'request_size' => 103,
   
'ssl_verifyresult' => 0,
   
'ssl_engines' =>
   array (
     
=> 'dynamic',
     
=> 'cswift',
     
=> 'chil',
     
=> 'atalla',
     
=> 'nuron',
     
=> 'ubsec',
     
=> 'aep',
     
=> 'sureware',
     
=> '4758cca',
   ),
   
'content_length_download' => 218,
   
'content_length_upload' => 0,
   
'content_type' => 'text/html',
   
'httpauth_avail' => 0,
   
'proxyauth_avail' => 0,
   
'num_connects' => 1,
   
'os_errno' => 0,
   
'error' => '',
 )
?>

Returns the HTTP response(s) as string on success, or FALSE on failure.

@@ -552,6 +584,9 @@ should also contain any parent messages.

void HttpMessage::prepend(HttpMessage message)

Prepends message(s) to the HTTP message.

Expects an HttpMessage object as parameter.

+

HttpMessage HttpMessage::reverse()

+

Reorders the message chain in reverse order.

+

Returns the most parent HttpMessage object.

void HttpMessage::rewind(void)

Implements Iterator.

bool HttpMessage::valid(void)

@@ -565,7 +600,7 @@ should also contain any parent messages.


http_querystring_object.c

HttpQueryString

-

void HttpQueryString::__construct([bool global = true[, mixed add])

+

final void HttpQueryString::__construct([bool global = true[, mixed add])

Creates a new HttpQueryString object instance.
Operates on and modifies $_GET and $_SERVER['QUERY_STRING'] if global is TRUE.

string HttpQueryString::toString()

@@ -580,6 +615,14 @@ Operates on and modifies $_GET and $_SERVER['QUERY_STRING'] if global is TRUE.Set query string entry/entries. NULL values will unset the variable.

HttpQueryString HttpQueryString::getInstance([bool global = true])

Get a single instance (differentiates between the global setting).

+

bool HttpQueryString::iconv(string ie, string oe)

+

Converts the query string from the source encoding ie to the target encoding oe.
+WARNING: Don't use any character set that can contain NUL bytes like UTF-16.

+

Returns TRUE on success or FALSE on failure.

+

string HttpQueryString::serialize()

+

Implements Serializable.

+

void HttpQueryString::unserialize(string serialized)

+

Implements Serializable.


http_request_object.c

HttpRequest

@@ -749,14 +792,9 @@ If the parameter is empty or omitted all response headers will be returned.

FALSE on failure, or an associative array containing all response headers.

If redirects were allowed and several responses were received, the data
references the last received response.

-

array HttpRequest::getResponseCookie([string name])

+

array HttpRequest::getResponseCookies([int flags[, array allowed_extras]])

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

-

Accepts a string as optional parameter specifying the name of the cookie to read.
-If the parameter is empty or omitted, an associative array with all received
-cookies will be returned.

-

Returns either an associative array with the cookie's name, value and any
-additional params of the cookie matching name if requested, FALSE on failure,
-or an array containing all received cookies as arrays.

+

Returns an array of stdClass objects like http_parse_cookie would return.

If redirects were allowed and several responses were received, the data
references the last received response.

string HttpRequest::getResponseBody()

@@ -811,16 +849,13 @@ may have made to the returned object.

Returns the complete web server response, including the headers in a form of a string.

HttpMessage HttpRequest::getHistory()

Get all sent requests and received responses as an HttpMessage object.

-

If you don't want to record history at all, set the instance variable
-HttpRequest::$recordHistory to FALSE.

+

If you want to record history, set the instance variable
+HttpRequest::$recordHistory to TRUE.

Returns an HttpMessage object representing the complete request/response
history.

The object references the last received response, use HttpMessage::getParentMessage()
to access the data of previously sent requests and received responses.

-

Note that the internal history is immutable, that means that any changes
-you make the the message list won't affect a history message list newly
-created by another call to HttpRequest::getHistory().

-

Throws HttpMalformedHeaderException, HttpEncodingException.

+

Throws HttpRuntimeException.

void HttpRequest::clearHistory()

Clear the history.

HttpMessage HttpRequest::send()

@@ -943,11 +978,13 @@ to something more appropriate than "no-cache"!

static bool HttpResponse::getGzip()

Get current gzipping setting.

Returns TRUE if GZip compression is enabled, else FALSE.

-

static bool HttpResponse::setCacheControl(string control[, int max_age = 0])

+

static bool HttpResponse::setCacheControl(string control[, int max_age = 0[, bool must_revalidate = true]])

Set a custom cache-control header, usually being "private" or "public";
The max_age parameter controls how long the cache entry is valid on the client side.

Expects a string parameter containing the primary cache control setting.
-Additionally accepts an int parameter specifying the max-age setting.

+Additionally accepts an int parameter specifying the max-age setting.
+Accepts an optional third bool parameter indicating whether the cache
+must be revalidated every request.

Returns TRUE on success, or FALSE if control does not match one of
"public" , "private" or "no-cache".

Throws HttpInvalidParamException if http.only_exceptions is TRUE.

@@ -1201,6 +1238,7 @@ http.cache_log is set.

  • HttpMessage::unserialize()
  • HttpMessage::detach()
  • HttpMessage::prepend()
  • +
  • HttpMessage::reverse()
  • HttpMessage::rewind()
  • HttpMessage::valid()
  • HttpMessage::next()
  • @@ -1217,6 +1255,9 @@ http.cache_log is set.

  • HttpQueryString::get()
  • HttpQueryString::set()
  • HttpQueryString::getInstance()
  • +
  • HttpQueryString::iconv()
  • +
  • HttpQueryString::serialize()
  • +
  • HttpQueryString::unserialize()
  • @@ -1256,7 +1297,7 @@ http.cache_log is set.

  • HttpRequest::getPutFile()
  • HttpRequest::getResponseData()
  • HttpRequest::getResponseHeader()
  • -
  • HttpRequest::getResponseCookie()
  • +
  • HttpRequest::getResponseCookies()
  • HttpRequest::getResponseBody()
  • HttpRequest::getResponseCode()
  • HttpRequest::getResponseStatus()
  • @@ -1328,7 +1369,7 @@ http.cache_log is set.

    -

    Generated at: Mon, 06 Feb 2006 13:45:38 +0100

    +

    Generated at: Mon, 20 Feb 2006 17:41:32 +0100