]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/http.php
WordPress 3.3.2
[autoinstalls/wordpress.git] / wp-includes / http.php
index 63cf97d1f9c4846b456762574556de2139a9ebe5..02b8750847730782d9e0c35a9c938b7c67f05da8 100644 (file)
@@ -130,7 +130,7 @@ function wp_remote_retrieve_headers(&$response) {
  *
  * @param array $response
  * @param string $header Header name to retrieve value from.
- * @return string The header value. Empty string on if incorrect parameter given, or if the header doesnt exist.
+ * @return string The header value. Empty string on if incorrect parameter given, or if the header doesn't exist.
  */
 function wp_remote_retrieve_header(&$response, $header) {
        if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
@@ -191,4 +191,34 @@ function wp_remote_retrieve_body(&$response) {
        return $response['body'];
 }
 
-?>
\ No newline at end of file
+/**
+ * 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 wp_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 wp_http_supports( $capabilities = array(), $url = null ) {
+       $objFetchSite = _wp_http_get_object();
+
+       $capabilities = wp_parse_args( $capabilities );
+
+       $count = count( $capabilities );
+
+       // If we have a numeric $capabilities array, spoof a wp_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 );
+}