Make WordPress Core

Ticket #16606: 16606.3.patch

File 16606.3.patch, 1.0 KB (added by hakre, 14 years ago)

Test streams transport HTTP? (correct Scheme specified by URL) and SSL support

  • wp-includes/class-http.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress-trunk
     
    868868         *
    869869         * @return boolean False means this class can not be used, true means it can.
    870870         */
    871         function test($args = array()) {
     871        function test( $args = array(), $url = '' ) {
    872872                if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
    873873                        return false;
    874874
    875                 return apply_filters('use_streams_transport', true, $args);
     875                $scheme = empty( $url ) ? 'http' : parse_url( $url, PHP_URL_SCHEME );
     876                $scheme = empty( $scheme ) ? '' : strtolower( $scheme );
     877
     878                $use = empty( $scheme ) ? false : in_array( $scheme, stream_get_wrappers() );
     879
     880                if ( $use && isset( $args['ssl'] ) && $args['ssl'] ) {
     881                        $use = in_array( 'ssl', stream_get_transports() );
     882                }
     883
     884                return (bool) apply_filters( 'use_streams_transport', $use, $args );
    876885        }
    877886}
    878887