Ticket #16606: 16606.7.patch
File 16606.7.patch, 4.6 KB (added by , 12 years ago) |
---|
-
wp-includes/class-http.php
### Eclipse Workspace Patch 1.0 #P wordpress-trunk
746 746 * @return boolean False means this class can not be used, true means it can. 747 747 */ 748 748 function test( $args = array() ) { 749 if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours 750 return false; 749 $is_ssl = !empty( $args['ssl'] ); 751 750 752 $is_ssl = isset($args['ssl']) && $args['ssl']; 751 // check if fsockopen has been disabled for 12 hours 752 $use = ( $option = get_option( 'disable_fsockopen', 0 ) ) && time() - $option > 43200; // 43200 = 12 hours 753 753 754 if ( ! $is_ssl && function_exists( 'fsockopen' ) ) 755 $use = true; 756 elseif ( $is_ssl && extension_loaded('openssl') && function_exists( 'fsockopen' ) ) 757 $use = true; 758 else 759 $use = false; 754 // check if there is a function named fsockopen 755 if ( $use ) 756 $use = function_exists( 'fsockopen' ); 760 757 761 return apply_filters('use_fsockopen_transport', $use, $args); 758 // check if openssl is available for SSL transports 759 if ( $use && $is_ssl ) 760 $use = extension_loaded( 'openssl' ); 761 762 return (bool) apply_filters('use_fsockopen_transport', $use, $args ); 762 763 } 763 764 } 764 765 … … 929 930 * 930 931 * @return boolean False means this class can not be used, true means it can. 931 932 */ 932 function test($args = array()) { 933 if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) ) 934 return false; 933 function test( $args = array(), $url = null ) { 934 $is_ssl = !empty( $args['ssl'] ); 935 935 936 return apply_filters('use_streams_transport', true, $args); 936 $scheme = empty($url) ? 'http' : strtolower( parse_url( $url, PHP_URL_SCHEME ) ); 937 938 $allowed_schemes = array( 'http', 'https' ); 939 940 // check if the requested scheme is allowed 941 $use = in_array( $scheme, $allowed_schemes ); 942 943 // check if the fopen function exists 944 if ( $use ) 945 $use = function_exists( 'fopen' ); 946 947 // check if url fopen is allowed 948 if ( $use ) 949 $use = function_exists( 'ini_get' ) && ini_get( 'allow_url_fopen' ); 950 951 // check if requested scheme has a stream wrapper 952 if ( $use ) 953 $use = in_array( $scheme, stream_get_wrappers() ); 954 955 // check specifically against openssl extension 956 if ( $use && $is_ssl ) 957 $use = extension_loaded( 'openssl' ); 958 959 // check if streams actually support ssl 960 if ( $use && $is_ssl ) 961 $use = in_array( 'ssl', stream_get_transports() ); 962 963 return (bool) apply_filters( 'use_streams_transport', $use, $args, $url ); 937 964 } 938 965 } 939 966 … … 1064 1091 $theBody = http_chunked_decode($theBody); 1065 1092 } 1066 1093 1067 if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) 1068 $theBody = http_inflate( $theBody ); 1094 if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) { 1095 if ( http_support( HTTP_SUPPORT_ENCODINGS ) ) { 1096 $theBody = http_inflate( $theBody ); 1097 } else { 1098 $theBody = WP_Http_Encoding::decompress( $theBody ); 1099 } 1100 } 1069 1101 1070 1102 if ( $r['stream'] ) { 1071 1103 if ( !WP_DEBUG ) … … 1097 1129 * @return boolean False means this class can not be used, true means it can. 1098 1130 */ 1099 1131 function test($args = array()) { 1100 return apply_filters('use_http_extension_transport', function_exists('http_request'), $args ); 1132 1133 $is_ssl = !empty( $args['ssl'] ); 1134 1135 // check if there is a function named http_support 1136 $use = function_exists( 'http_support' ); 1137 1138 // check if there is support for requests 1139 if ( $use ) 1140 $use = http_support( HTTP_SUPPORT_REQUESTS ); 1141 1142 // check if there is support for SSL requests 1143 if ( $use && $is_ssl ) 1144 $use = http_support( HTTP_SUPPORT_SSLREQUESTS ); 1145 1146 return (bool) apply_filters( 'use_http_extension_transport', $use, $args ); 1101 1147 } 1102 1148 } 1103 1149 … … 1313 1359 * @return boolean False means this class can not be used, true means it can. 1314 1360 */ 1315 1361 function test($args = array()) { 1316 if ( function_exists('curl_init') && function_exists('curl_exec') )1317 return apply_filters('use_curl_transport', true, $args);1318 1362 1319 return false; 1363 $is_ssl = !empty( $args['ssl'] ); 1364 1365 // check if there is a function named curl_init 1366 $use = function_exists( 'curl_init' ); 1367 1368 // check if there is a function named curl_exec 1369 if ( $use ) 1370 $use = function_exists( 'curl_exec' ); 1371 1372 // check if openssl is available for SSL transports 1373 if ( $use && $is_ssl ) 1374 $use = extension_loaded( 'openssl' ); 1375 1376 return (bool) apply_filters( 'use_curl_transport', $use, $args ); 1320 1377 } 1321 1378 } 1322 1379