示例#1
0
/**
 * Determines if there is an HTTP Transport that can process this request.
 *
 * @since 3.2.0
 *
 * @param array  $capabilities Array of capabilities to test or a nxt_remote_request() $args array.
 * @param string $url Optional.  If given, will check if the URL requires SSL and adds that requirement to the capabilities array.
 *
 * @return bool
 */
function nxt_http_supports($capabilities = array(), $url = null)
{
    $objFetchSite = _nxt_http_get_object();
    $capabilities = nxt_parse_args($capabilities);
    $count = count($capabilities);
    // If we have a numeric $capabilities array, spoof a nxt_remote_request() associative $args array
    if ($count && count(array_filter(array_keys($capabilities), 'is_numeric')) == $count) {
        $capabilities = array_combine(array_values($capabilities), array_fill(0, $count, true));
    }
    if ($url && !isset($capabilities['ssl'])) {
        $scheme = parse_url($url, PHP_URL_SCHEME);
        if ('https' == $scheme || 'ssl' == $scheme) {
            $capabilities['ssl'] = true;
        }
    }
    return (bool) $objFetchSite->_get_first_available_transport($capabilities);
}
示例#2
0
/**
 * Retrieve the raw response from the HTTP request using the HEAD method.
 *
 * @see nxt_remote_request() For more information on the response array format.
 *
 * @since 2.7.0
 *
 * @param string $url Site URL to retrieve.
 * @param array $args Optional. Override the defaults.
 * @return nxt_Error|array The response or nxt_Error on failure.
 */
function nxt_remote_head($url, $args = array())
{
    $objFetchSite = _nxt_http_get_object();
    return $objFetchSite->head($url, $args);
}