HTTP

Table of Contents

The HttpDeflateStream class

Class synopsis

HttpDeflateStream
class HttpDeflateStream {
public __construct ([ int $flags = 0 ] )
static public HttpDeflateStream factory ([ int $flags = 0 [, string $class_name = "HttpDeflateStream" ]] )
public string finish ([ string $data ] )
public string flush ([ string $data ] )
public string update ( string $data )
}

Class Members

Predefined Constants

Type Name Description
int TYPE_GZIP gzip encoding
int TYPE_ZLIB zlib AKA deflate encoding
int TYPE_RAW raw deflate encoding
int LEVEL_DEF default compression level
int LEVEL_MIN minimum compression level
int LEVEL_MAX maximum compression level
int STRATEGY_DEF default strategy
int STRATEGY_FILT filtered strategy
int STRATEGY_HUFF Huffman strategy
int STRATEGY_RLE RLE strategy
int STRATEGY_FIXED fixed strategy
int FLUSH_NONE no forced flush
int FLUSH_SYNC synching flush
int FLUSH_FULL full flush

Examples

Example #1 A HttpDeflateStream example

<?php
$stream 
= new HttpDeflateStream(
    
HttpDeflateStream::TYPE_GZIP |
    
HttpDeflateStream::LEVEL_MAX |
    
HttpDeflateStream::FLUSH_SYNC);

echo 
$stream->update($data);
echo 
$stream->finish();
?>

The HttpInflateStream class

Class synopsis

HttpInflateStream
class HttpInflateStream {
public __construct ([ int $flags = 0 ] )
public HttpInflateStream factory ([ int $flags = 0 [, string $class_name = "HttpInflateStream" ]] )
public string finish ([ string $data ] )
public string flush ([ string $data ] )
public string update ( string $data )
}

Class Members

Constants

Type Name Description
int FLUSH_NONE no forced flush
int FLUSH_SYNC synching flush
int FLUSH_FULL full flush

Note:

Flushing usually has no effect on inflate streams.

Examples

Example #1 A HttpInflateStream example

<?php
$stream 
= new HttpInflateStream;
echo 
$stream->update($data);
echo 
$stream->finish();
?>

The HttpMessage class

Class synopsis

HttpMessage
class HttpMessage implements Iterator , Countable , Serializable {
public void addHeaders ( array $headers [, bool $append = false ] )
public __construct ([ string $message ] )
public HttpMessage detach ( void )
static public HttpMessage factory ([ string $raw_message [, string $class_name = "HttpMessage" ]] )
static public HttpMessage fromEnv ( int $message_type [, string $class_name = "HttpMessage" ] )
static public HttpMessage fromString ([ string $raw_message [, string $class_name = "HttpMessage" ]] )
public string getBody ( void )
public string getHeader ( string $header )
public array getHeaders ( void )
public string getHttpVersion ( void )
public HttpMessage getParentMessage ( void )
public string getRequestMethod ( void )
public string getRequestUrl ( void )
public int getResponseCode ( void )
public string getResponseStatus ( void )
public int getType ( void )
public string guessContentType ( string $magic_file [, int $magic_mode = MAGIC_MIME ] )
public void prepend ( HttpMessage $message [, bool $top = true ] )
public HttpMessage reverse ( void )
public bool send ( void )
public void setBody ( string $body )
public void setHeaders ( array $headers )
public bool setHttpVersion ( string $version )
public bool setRequestMethod ( string $method )
public bool setRequestUrl ( string $url )
public bool setResponseCode ( int $code )
public bool setResponseStatus ( string $status )
public void setType ( int $type )
public HttpRequest|HttpResponse toMessageTypeObject ( void )
public string toString ([ bool $include_parent = false ] )
}

Class Members

Properties

Instance Properties
Modifiers Type Name Description
protected int type message type
protected string body message body
protected float httpVersion HTTP protocol version
protected array headers message headers
protected string requestMethod request method name
protected requestUrl string request URL
protected int responseCode response code
protected string responseStatus response status message
protected HttpMessage parentMessage reference to parent message

Note:

None of these default properties can be accessed by reference, array key/index notation nor be used in increment or decrement operations.

Predefined Constants

Type Name Description
int TYPE_NONE message has is of no specific type
int TYPE_REQUEST message is a request style HTTP message
int TYPE_RESPONSE message is a response style HTTP message

The HttpQueryString class

Class synopsis

HttpQueryString
class HttpQueryString implements ArrayAccess , Serializable {
final public __construct ([ bool $global = true [, mixed $add ]] )
public mixed get ([ string $key [, mixed $type = 0 [, mixed $defval = NULL [, bool $delete = false ]]]] )
public HttpQueryString mod ( mixed $params )
public string set ( mixed $params )
static public HttpQueryString singleton ([ bool $global = true ] )
public array toArray ( void )
public string toString ( void )
public bool xlate ( string $ie , string $oe )
}

Class Members

Properties

Instance Properties
Modifiers Type Name Description
private array queryArray query parameters
private string queryString serialized query parameters
Static Properties
Modifiers Type Name Description
private array instance holds singletons

Predefined Constants

Type Name Description
int TYPE_BOOL retrieve query param as bool
int TYPE_INT retrieve query param as int
int TYPE_FLOAT retrieve query param as float
int TYPE_STRING retrieve query param as string
int TYPE_ARRAY retrieve query param as array
int TYPE_OBJECT retrieve query param as object

The HttpRequest

Class synopsis

HttpRequest
class HttpRequest {
public bool addCookies ( array $cookies )
public bool addHeaders ( array $headers )
public bool addPostFields ( array $post_data )
public bool addPostFile ( string $name , string $file [, string $content_type = "application/x-octetstream" ] )
public bool addPutData ( string $put_data )
public bool addQueryData ( array $query_params )
public bool addRawPostData ( string $raw_post_data )
public bool addSslOptions ( array $options )
public void clearHistory ( void )
public __construct ([ string $url [, int $request_method = HTTP_METH_GET [, array $options ]]] )
public bool enableCookies ( void )
public string getContentType ( void )
public array getCookies ( void )
public array getHeaders ( void )
public HttpMessage getHistory ( void )
public int getMethod ( void )
public array getOptions ( void )
public array getPostFields ( void )
public array getPostFiles ( void )
public string getPutData ( void )
public string getPutFile ( void )
public string getQueryData ( void )
public string getRawPostData ( void )
public string getRawRequestMessage ( void )
public string getRawResponseMessage ( void )
public HttpMessage getRequestMessage ( void )
public string getResponseBody ( void )
public int getResponseCode ( void )
public array getResponseCookies ([ int $flags = 0 [, array $allowed_extras ]] )
public array getResponseData ( void )
public mixed getResponseHeader ([ string $name ] )
public mixed getResponseInfo ([ string $name ] )
public HttpMessage getResponseMessage ( void )
public string getResponseStatus ( void )
public array getSslOptions ( void )
public string getUrl ( void )
public bool resetCookies ([ bool $session_only = false ] )
public HttpMessage send ( void )
bool setBody ([ string $request_body_data ] )
public bool setContentType ( string $content_type )
public bool setCookies ([ array $cookies ] )
public bool setHeaders ([ array $headers ] )
public bool setMethod ( int $request_method )
public bool setOptions ([ array $options ] )
public bool setPostFields ( array $post_data )
public bool setPostFiles ( array $post_files )
public bool setPutData ([ string $put_data ] )
public bool setPutFile ([ string $file = "" ] )
public bool setQueryData ( mixed $query_data )
public bool setRawPostData ([ string $raw_post_data ] )
public bool setSslOptions ([ array $options ] )
public bool setUrl ( string $url )
}

Class Members

Properties

Instance Properties
Modifiers Type Name Description
private array options request options to configure the request; see request options
private array postFields form data:
array("fieldname" => "fieldvalue")
private array postFiles files to upload:
array(array("name" => "image", "file" => "/home/u/images/u.png", "type" => "image/png"))
private array responseInfo information (statistical) about the request/response; see Request/response information
private HttpMessage responseMessage the response message
private integer responseCode the numerical response code
private string responseStatus the literal response status text
private integer method the request method to use
private string url the request url
private string contentType the content type to use for raw post requests
private string rawPostData raw post data
private string queryData query parameters
private string putFile the file to upload with a PUT request
private string putData raw data to upload with a PUT request
private HttpMessage history the whole request/response history if history logging is enabled
public boolean recordHistory whether to enable history logging

Predefined Constants

Type Name Description
integer METH_GET GET request method
integer METH_HEAD HEAD request method
integer METH_POST POST request method
integer METH_PUT PUT request method
integer METH_DELETE DELETE request method
integer METH_OPTIONS OPTIONS request method
integer METH_TRACE TRACE request method
integer METH_CONNECT CONNECT request method
integer METH_PROPFIND PROPFIND request method
integer METH_PROPPATCH PROPPATCH request method
integer METH_MKCOL MKCOL request method
integer METH_COPY COPY request method
integer METH_MOVE MOVE request method
integer METH_LOCK LOCK request method
integer METH_UNLOCK UNLOCK request method
integer METH_VERSION_CONTROL VERSION-CONTROL request method
integer METH_REPORT REPORT request method
integer METH_CHECKOUT CHECKOUT request method
integer METH_CHECKIN CHECKIN request method
integer METH_UNCHECKOUT UNCHECKOUT request method
integer METH_MKWORKSPACE MKWORKSPACE request method
integer METH_UPDATE UPDATE request method
integer METH_LABEL LABEL request method
integer METH_MERGE MERGE request method
integer METH_BASELINE_CONTROL BASELINE-CONTROL request method
integer METH_MKACTIVITY MKACTIVITY request method
integer METH_ACL ACL request method
integer VERSION_1_0 HTTP protocol version 1.0
integer VERSION_1_1 HTTP protocol version 1.1
integer VERSION_ANY any HTTP protocol version
integer AUTH_BASIC basic authentication
integer AUTH_DIGEST digest authentication
integer AUTH_NTLM NTLM authentication
integer AUTH_GSSNEG GSS negotiate authentication
integer AUTH_ANY any authentication
integer PROXY_SOCKS4 SOCKS v4 proxy
integer PROXY_SOCKS5 SOCKS v5 proxy
integer PROXY_HTTP HTTP proxy
integer SSL_VERSION_TLSv1 use TLS v1
integer SSL_VERSION_SSLv2 use SSL v2
integer SSL_VERSION_SSLv3 use SSL v3
integer SSL_VERSION_ANY use any SSL/TLS method
integer IPRESOLVE_V4 resolve via IPv4 only
integer IPRESOLVE_V6 resolve via IPv6 only
integer IPRESOLVE_ANY use any resolving methods

The HttpRequestPool class

Class synopsis

HttpRequestPool
class HttpRequestPool implements Iterator , Countable {
public bool attach ( HttpRequest $request )
public __construct ([ HttpRequest $request [, HttpRequest $... ]] )
void __destruct ( void )
bool detach ( HttpRequest $request )
array getAttachedRequests ( void )
array getFinishedRequests ( void )
void reset ( void )
bool send ( void )
protected bool socketPerform ( void )
protected bool socketSelect ([ float $timeout = 0 ] )
}

Class Members

Properties

The HttpRequestPool class does not have any properties.

Predefined Constants

The HttpRequestPool class does not have any constants.

The HttpResponse

Class synopsis

HttpResponse
class HttpResponse {
static void capture ( void )
static int getBufferSize ( void )
static bool getCache ( void )
static string getCacheControl ( void )
static string getContentDisposition ( void )
static string getContentType ( void )
static string getData ( void )
static string getETag ( void )
static string getFile ( void )
static bool getGzip ( void )
static mixed getHeader ([ string $name ] )
static int getLastModified ( void )
static string getRequestBody ( void )
static resource getRequestBodyStream ( void )
static array getRequestHeaders ( void )
static resource getStream ( void )
static float getThrottleDelay ( void )
static string guessContentType ( string $magic_file [, int $magic_mode = MAGIC_MIME ] )
static void redirect ([ string $url [, array $params [, bool $session = false [, int $status ]]]] )
static bool send ([ bool $clean_ob = true ] )
static bool setBufferSize ( int $bytes )
static bool setCache ( bool $cache )
static bool setCacheControl ( string $control [, int $max_age = 0 [, bool $must_revalidate = true ]] )
static bool setContentDisposition ( string $filename [, bool $inline = false ] )
static bool setContentType ( string $content_type )
static bool setData ( mixed $data )
static bool setETag ( string $etag )
static bool setFile ( string $file )
static bool setGzip ( bool $gzip )
static bool setHeader ( string $name [, mixed $value [, bool $replace = true ]] )
static bool setLastModified ( int $timestamp )
static bool setStream ( resource $stream )
static bool setThrottleDelay ( float $seconds )
static bool status ( int $status )
}

Class Members

Properties

Static Properties
Modifiers Type Name Description
protected boolean cache whether caching the response should be attempted
protected boolean gzip whether the sent entity should be gzip'ed on the fly
protected string eTag the generated or custom ETag
protected integer lastModified the generated or custom timestamp of last modification
protected string cacheControl Cache-Control setting
protected string contentType the Content-Type of the sent entity
protected string contentDisposition the Content-Disposition of the sent entity
protected integer bufferSize the chunk buffer size used for throttling
protected double throttleDelay the seconds to delay when throttling

Predefined Constants

Type Name Description
integer REDIRECT guess applicable redirect method
integer REDIRECT_PERM permanent redirect (301 Moved permanently)
integer REDIRECT_FOUND standard redirect (302 Found)
integer REDIRECT_POST redirect applicable to POST requests (303 See other)
integer REDIRECT_PROXY proxy redirect (305 Use proxy)
integer REDIRECT_TEMP temporary redirect (307 Temporary Redirect)