Ticket #8702: 8702.2.diff
File 8702.2.diff, 5.1 KB (added by , 16 years ago) |
---|
-
http.php
78 78 * Tests all of the objects and returns the object that passes. Also caches 79 79 * that object to be used later. 80 80 * 81 * The order for the GET/HEAD requests are Streams, HTTP Extension, Fopen,82 * and finally Fsockopen. fsockopen() is used last, because it has the most83 * overhead in its implementation. There isn't any real way around it, since84 * redirects have to be supported, much the same way the other transports85 * also handle redirects.81 * The order for the GET/HEAD requests are HTTP Extension, cURL, Streams, 82 * Fopen, and finally Fsockopen. fsockopen() is used last, because it has 83 * the most overhead in its implementation. There isn't any real way around 84 * it, since redirects have to be supported, much the same way the other 85 * transports also handle redirects. 86 86 * 87 87 * There are currently issues with "localhost" not resolving correctly with 88 88 * DNS. This may cause an error "failed to open stream: A connection attempt … … 141 141 * to send content, but the streams transport can. This is a limitation that 142 142 * is addressed here, by just not including that transport. 143 143 * 144 * The order for the POST requests are HTTP Extension, cURL, Streams and 145 * finally Fsockopen. fsockopen() is used last, because it has the most 146 * overhead in its implementation. There isn't any real way around it, 147 * since redirects have to be supported, much the same way the other 148 * transports also handle redirects. 149 * 144 150 * @since 2.7.0 145 151 * @access private 146 152 * … … 154 160 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { 155 161 $working_transport['exthttp'] = new WP_Http_ExtHttp(); 156 162 $blocking_transport[] = &$working_transport['exthttp']; 163 } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { 164 $working_transport['curl'] = new WP_Http_Curl(); 165 $blocking_transport[] = &$working_transport['curl']; 157 166 } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { 158 167 $working_transport['streams'] = new WP_Http_Streams(); 159 168 $blocking_transport[] = &$working_transport['streams']; … … 230 239 'timeout' => apply_filters( 'http_request_timeout', 5), 231 240 'redirection' => apply_filters( 'http_request_redirection_count', 5), 232 241 'httpversion' => apply_filters( 'http_request_version', '1.0'), 233 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ),242 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), 234 243 'blocking' => true, 235 244 'headers' => array(), 'body' => null 236 245 ); … … 787 796 'max_redirects' => $r['redirection'], 788 797 'protocol_version' => (float) $r['httpversion'], 789 798 'header' => $strHeaders, 790 'timeout' => $r['timeout'] 799 'timeout' => $r['timeout'], 800 'verify_peer' => false 791 801 ) 792 802 ); 793 803 … … 917 927 'redirect' => $r['redirection'], 918 928 'useragent' => $r['user-agent'], 919 929 'headers' => $r['headers'], 930 'ssl' => array( 'verifypeer' => false, 'verifyhost' => false ) 920 931 ); 921 932 922 933 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts … … 1007 1018 $r['timeout'] = 1; 1008 1019 1009 1020 $handle = curl_init(); 1021 1010 1022 curl_setopt( $handle, CURLOPT_URL, $url); 1023 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); 1024 curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, false ); 1025 curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false ); 1026 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); 1027 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] ); 1028 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); 1029 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 1011 1030 1012 // The cURL extension requires that the option be set for the HEAD to 1013 // work properly. 1014 if ( 'HEAD' === $r['method'] ) { 1015 curl_setopt( $handle, CURLOPT_NOBODY, true ); 1031 switch ( $r['method'] ) { 1032 case 'HEAD': 1033 curl_setopt( $handle, CURLOPT_NOBODY, true ); 1034 break; 1035 case 'POST': 1036 curl_setopt( $handle, CURLOPT_POST, true ); 1037 curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); 1038 break; 1016 1039 } 1017 1040 1018 if ( true === $r['blocking'] ) {1041 if ( true === $r['blocking'] ) 1019 1042 curl_setopt( $handle, CURLOPT_HEADER, true ); 1020 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); 1021 } else { 1043 else 1022 1044 curl_setopt( $handle, CURLOPT_HEADER, false ); 1023 curl_setopt( $handle, CURLOPT_NOBODY, true );1024 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 );1025 }1026 1045 1027 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );1028 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 );1029 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );1030 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );1031 1032 1046 // The option doesn't work with safe mode or when open_basedir is set. 1033 1047 if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) 1034 1048 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );