[ Index ] |
WordPress Cross Reference |
[Source view] [Print] [Project Stats]
Simple and uniform HTTP request API. Standardizes the HTTP requests for WordPress. Handles cookies, gzip encoding and decoding, chunk decoding, if HTTP 1.1 and various other difficult HTTP protocol implementations.
File Size: | 1954 lines (64 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
WP_Http:: (14 methods):
request()
_get_first_available_transport()
_dispatch_request()
post()
get()
head()
processResponse()
processHeaders()
buildCookieHeader()
chunkTransferDecode()
block_request()
make_absolute_url()
handle_redirects()
is_ip_address()
WP_Http_Streams:: (3 methods):
request()
verify_ssl_certificate()
test()
WP_HTTP_Fsockopen:: (0 methods):
WP_Http_Curl:: (4 methods):
request()
stream_headers()
stream_body()
test()
WP_HTTP_Proxy:: (9 methods):
is_enabled()
use_authentication()
host()
port()
username()
password()
authentication()
authentication_header()
send_through_proxy()
WP_Http_Cookie:: (4 methods):
__construct()
test()
getHeaderValue()
getFullHeader()
WP_Http_Encoding:: (7 methods):
compress()
decompress()
compatible_gzinflate()
accept_encoding()
content_encoding()
should_decode()
is_available()
request( $url, $args = array() X-Ref |
Send a HTTP request to a URI. The body and headers are part of the arguments. The 'body' argument is for the body and will accept either a string or an array. The 'headers' argument should be an array, but a string is acceptable. If the 'body' argument is an array, then it will automatically be escaped using http_build_query(). The only URI that are supported in the HTTP Transport implementation are the HTTP and HTTPS protocols. The defaults are 'method', 'timeout', 'redirection', 'httpversion', 'blocking' and 'user-agent'. Accepted 'method' values are 'GET', 'POST', and 'HEAD', some transports technically allow others, but should not be assumed. The 'timeout' is used to sent how long the connection should stay open before failing when no response. 'redirection' is used to track how many redirects were taken and used to sent the amount for other transports, but not all transports accept setting that value. The 'httpversion' option is used to sent the HTTP version and accepted values are '1.0', and '1.1' and should be a string. The 'user-agent' option is the user-agent and is used to replace the default user-agent, which is 'WordPress/WP_Version', where WP_Version is the value from $wp_version. The 'blocking' parameter can be used to specify if the calling code requires the result of the HTTP request. If set to false, the request will be sent to the remote server, and processing returned to the calling code immediately, the caller will know if the request suceeded or failed, but will not receive any response from the remote server. param: string $url URI resource. param: str|array $args Optional. Override the defaults. return: array|object Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
_get_first_available_transport( $args, $url = null ) X-Ref |
Tests which transports are capable of supporting the request. param: array $args Request arguments param: string $url URL to Request return: string|bool Class name for the first transport that claims to support the request. False if no transport claims to support the request. |
_dispatch_request( $url, $args ) X-Ref |
Dispatches a HTTP request to a supporting transport. Tests each transport in order to find a transport which matches the request arguments. Also caches the transport instance to be used later. The order for requests is cURL, and then PHP Streams. param: string $url URL to Request param: array $args Request arguments return: array|object Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
post($url, $args = array() X-Ref |
Uses the POST HTTP method. Used for sending data that is expected to be in the body. param: string $url URI resource. param: str|array $args Optional. Override the defaults. return: array|object Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
get($url, $args = array() X-Ref |
Uses the GET HTTP method. Used for sending data that is expected to be in the body. param: string $url URI resource. param: str|array $args Optional. Override the defaults. return: array|object Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
head($url, $args = array() X-Ref |
Uses the HEAD HTTP method. Used for sending data that is expected to be in the body. param: string $url URI resource. param: str|array $args Optional. Override the defaults. return: array|object Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error |
processResponse($strResponse) X-Ref |
Parses the responses and splits the parts into headers and body. param: string $strResponse The full response string return: array Array with 'headers' and 'body' keys. |
processHeaders( $headers, $url = '' ) X-Ref |
Transform header string into an array. If an array is given then it is assumed to be raw header data with numeric keys with the headers as the values. No headers must be passed that were already processed. param: string|array $headers param: string $url The URL that was requested return: array Processed string headers. If duplicate headers are encountered, |
buildCookieHeader( &$r ) X-Ref |
Takes the arguments for a ::request() and checks for the cookie array. If it's found, then it upgrades any basic name => value pairs to WP_Http_Cookie instances, which are each parsed into strings and added to the Cookie: header (within the arguments array). Edits the array by reference. param: array $r Full array of args passed into ::request() |
chunkTransferDecode( $body ) X-Ref |
Decodes chunk transfer-encoding, based off the HTTP 1.1 specification. Based off the HTTP http_encoding_dechunk function. param: string $body Body content return: string Chunked decoded body on success or raw body on failure. |
block_request($uri) X-Ref |
Block requests through the proxy. Those who are behind a proxy and want to prevent access to certain hosts may do so. This will prevent plugins from working and core functionality, if you don't include api.wordpress.org. You block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true in your wp-config.php file and this will only allow localhost and your blog to make requests. The constant WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted. param: string $uri URI of url. return: bool True to block, false to allow. |
make_absolute_url( $maybe_relative_path, $url ) X-Ref |
No description |
handle_redirects( $url, $args, $response ) X-Ref |
Handles HTTP Redirects and follows them if appropriate. param: string $url The URL which was requested. param: array $args The Arguements which were used to make the request. param: array $response The Response of the HTTP request. return: false|object False if no redirect is present, a WP_HTTP or WP_Error result otherwise. |
is_ip_address( $maybe_ip ) X-Ref |
Determines if a specified string represents an IP address or not. This function also detects the type of the IP address, returning either '4' or '6' to represent a IPv4 and IPv6 address respectively. This does not verify if the IP is a valid IP, only that it appears to be an IP address. param: string $maybe_ip A suspected IP address return: integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure |
Class: WP_Http_Streams - X-Ref
HTTP request method uses PHP Streams to retrieve the url.request($url, $args = array() X-Ref |
Send a HTTP request to a URI using PHP Streams. param: string $url URI resource. param: string|array $args Optional. Override the defaults. return: array 'headers', 'body', 'response', 'cookies' and 'filename' keys. |
verify_ssl_certificate( $stream, $host ) X-Ref |
Verifies the received SSL certificate against it's Common Names and subjectAltName fields PHP's SSL verifications only verify that it's a valid Certificate, it doesn't verify if the certificate is valid for the hostname which was requested. This function verifies the requested hostname against certificate's subjectAltName field, if that is empty, or contains no DNS entries, a fallback to the Common Name field is used. IP Address support is included if the request is being made to an IP address. param: stream $stream The PHP Stream which the SSL request is being made over param: string $host The hostname being requested return: bool If the cerficiate presented in $stream is valid for $host |
test( $args = array() X-Ref |
Whether this class can be used for retrieving an URL. return: boolean False means this class can not be used, true means it can. |
Class: WP_HTTP_Fsockopen - X-Ref
Deprecated HTTP Transport method which used fsockopen.Class: WP_Http_Curl - X-Ref
HTTP request method uses Curl extension to retrieve the url.request($url, $args = array() X-Ref |
Send a HTTP request to a URI using cURL extension. param: string $url param: str|array $args Optional. Override the defaults. return: array 'headers', 'body', 'response', 'cookies' and 'filename' keys. |
stream_headers( $handle, $headers ) X-Ref |
Grab the headers of the cURL request Each header is sent individually to this callback, so we append to the $header property for temporary storage return: int |
stream_body( $handle, $data ) X-Ref |
Grab the body of the cURL request The contents of the document are passed in chunks, so we append to the $body property for temporary storage. Returning a length shorter than the length of $data passed in will cause cURL to abort the request as "completed" return: int |
test( $args = array() X-Ref |
Whether this class can be used for retrieving an URL. return: boolean False means this class can not be used, true means it can. |
Class: WP_HTTP_Proxy - X-Ref
Adds Proxy support to the WordPress HTTP API.is_enabled() X-Ref |
Whether proxy connection should be used. return: bool |
use_authentication() X-Ref |
Whether authentication should be used. return: bool |
host() X-Ref |
Retrieve the host for the proxy server. return: string |
port() X-Ref |
Retrieve the port for the proxy server. return: string |
username() X-Ref |
Retrieve the username for proxy authentication. return: string |
password() X-Ref |
Retrieve the password for proxy authentication. return: string |
authentication() X-Ref |
Retrieve authentication string for proxy authentication. return: string |
authentication_header() X-Ref |
Retrieve header string for proxy authentication. return: string |
send_through_proxy( $uri ) X-Ref |
Whether URL should be sent through the proxy server. We want to keep localhost and the blog URL from being sent through the proxy server, because some proxies can not handle this. We also have the constant available for defining other hosts that won't be sent through the proxy. param: string $uri URI to check. return: bool True, to send through the proxy and false if, the proxy should not be used. |
Class: WP_Http_Cookie - X-Ref
Internal representation of a single cookie.__construct( $data, $requested_url = '' ) X-Ref |
Sets up this cookie object. The parameter $data should be either an associative array containing the indices names below or a header string detailing it. If it's an array, it should include the following elements: <ol> <li>Name</li> <li>Value - should NOT be urlencoded already.</li> <li>Expires - (optional) String or int (UNIX timestamp).</li> <li>Path (optional)</li> <li>Domain (optional)</li> <li>Port (optional)</li> </ol> param: string|array $data Raw cookie data. param: string $requested_url The URL which the cookie was set on, used for default 'domain' and 'port' values |
test( $url ) X-Ref |
Confirms that it's OK to send this cookie to the URL checked against. Decision is based on RFC 2109/2965, so look there for details on validity. param: string $url URL you intend to send this cookie to return: boolean true if allowed, false otherwise. |
getHeaderValue() X-Ref |
Convert cookie name and value back to header string. return: string Header encoded cookie name and value. |
getFullHeader() X-Ref |
Retrieve cookie header for usage in the rest of the WordPress HTTP API. return: string |
Class: WP_Http_Encoding - X-Ref
Implementation for deflate and gzip transfer encodings.compress( $raw, $level = 9, $supports = null ) X-Ref |
Compress raw string using the deflate format. Supports the RFC 1951 standard. param: string $raw String to compress. param: int $level Optional, default is 9. Compression level, 9 is highest. param: string $supports Optional, not used. When implemented it will choose the right compression based on what the server supports. return: string|bool False on failure. |
decompress( $compressed, $length = null ) X-Ref |
Decompression of deflated string. Will attempt to decompress using the RFC 1950 standard, and if that fails then the RFC 1951 standard deflate will be attempted. Finally, the RFC 1952 standard gzip decode will be attempted. If all fail, then the original compressed string will be returned. param: string $compressed String to decompress. param: int $length The optional length of the compressed data. return: string|bool False on failure. |
compatible_gzinflate($gzData) X-Ref |
Decompression of deflated string while staying compatible with the majority of servers. Certain Servers will return deflated data with headers which PHP's gzinflate() function cannot handle out of the box. The following function has been created from various snippets on the gzinflate() PHP documentation. Warning: Magic numbers within. Due to the potential different formats that the compressed data may be returned in, some "magic offsets" are needed to ensure proper decompression takes place. For a simple progmatic way to determine the magic offset in use, see: http://core.trac.wordpress.org/ticket/18273 param: string $gzData String to decompress. return: string|bool False on failure. |
accept_encoding( $url, $args ) X-Ref |
What encoding types to accept and their priority values. return: string Types of encoding to accept. |
content_encoding() X-Ref |
What encoding the content used when it was compressed to send in the headers. return: string Content-Encoding string to send in the header. |
should_decode($headers) X-Ref |
Whether the content be decoded based on the headers. param: array|string $headers All of the available headers. return: bool |
is_available() X-Ref |
Whether decompression and compression are supported by the PHP version. Each function is tested instead of checking for the zlib extension, to ensure that the functions all exist in the PHP version and aren't disabled. return: bool |
Generated: Tue Mar 25 01:41:18 2014 | WordPress honlapkészítés: online1.hu |