Ticket #8702: 8702.diff
| File 8702.diff, 5.0 KB (added by , 17 years ago) |
|---|
-
wp-includes/http.php
69 69 * Tests all of the objects and returns the object that passes. Also caches 70 70 * that object to be used later. 71 71 * 72 * The order for the GET/HEAD requests are Streams, HTTP Extension, Fopen,73 * and finally Fsockopen. fsockopen() is used last, because it has the most74 * overhead in its implementation. There isn't any real way around it, since75 * redirects have to be supported, much the same way the other transports76 * also handle redirects.72 * The order for the GET/HEAD requests are HTTP Extension, cURL, Streams, 73 * Fopen, and finally Fsockopen. fsockopen() is used last, because it has 74 * the most overhead in its implementation. There isn't any real way around 75 * it, since redirects have to be supported, much the same way the other 76 * transports also handle redirects. 77 77 * 78 78 * There are currently issues with "localhost" not resolving correctly with 79 79 * DNS. This may cause an error "failed to open stream: A connection attempt … … 129 129 * to send content, but the streams transport can. This is a limitation that 130 130 * is addressed here, by just not including that transport. 131 131 * 132 * The order for the POST requests are HTTP Extension, cURL, Streams and 133 * finally Fsockopen. fsockopen() is used last, because it has the most 134 * overhead in its implementation. There isn't any real way around it, 135 * since redirects have to be supported, much the same way the other 136 * transports also handle redirects. 137 * 132 138 * @since 2.7 133 139 * @access private 134 140 * … … 142 148 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { 143 149 $working_transport['exthttp'] = new WP_Http_ExtHttp(); 144 150 $blocking_transport[] = &$working_transport['exthttp']; 151 } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { 152 $working_transport['curl'] = new WP_Http_Curl(); 153 $blocking_transport[] = &$working_transport['curl']; 145 154 } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { 146 155 $working_transport['streams'] = new WP_Http_Streams(); 147 156 $blocking_transport[] = &$working_transport['streams']; … … 215 224 'timeout' => apply_filters( 'http_request_timeout', 5), 216 225 'redirection' => apply_filters( 'http_request_redirection_count', 5), 217 226 'httpversion' => apply_filters( 'http_request_version', '1.0'), 218 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ),227 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), 219 228 'blocking' => true, 220 229 'headers' => array(), 'body' => null 221 230 ); … … 769 778 'max_redirects' => $r['redirection'], 770 779 'protocol_version' => (float) $r['httpversion'], 771 780 'header' => $strHeaders, 772 'timeout' => $r['timeout'] 781 'timeout' => $r['timeout'], 782 'verify_peer' => false 773 783 ) 774 784 ); 775 785 … … 899 909 'redirect' => $r['redirection'], 900 910 'useragent' => $r['user-agent'], 901 911 'headers' => $r['headers'], 912 'ssl' => array( 'verifypeer' => false, 'verifyhost' => false ) 902 913 ); 903 914 904 915 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts … … 988 999 $r['timeout'] = 1; 989 1000 990 1001 $handle = curl_init(); 1002 991 1003 curl_setopt( $handle, CURLOPT_URL, $url); 1004 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); 1005 curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, false ); 1006 curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false ); 1007 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); 1008 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] ); 1009 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); 1010 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 992 1011 993 if ( 'HEAD' === $r['method'] ) { 994 curl_setopt( $handle, CURLOPT_NOBODY, true ); 1012 switch ( $r['method'] ) { 1013 case 'HEAD': 1014 curl_setopt( $handle, CURLOPT_NOBODY, true ); 1015 break; 1016 case 'POST': 1017 curl_setopt( $handle, CURLOPT_POST, true ); 1018 curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); 1019 break; 995 1020 } 996 1021 997 if ( true === $r['blocking'] ) {1022 if ( true === $r['blocking'] ) 998 1023 curl_setopt( $handle, CURLOPT_HEADER, true ); 999 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); 1000 } else { 1024 else 1001 1025 curl_setopt( $handle, CURLOPT_HEADER, false ); 1002 curl_setopt( $handle, CURLOPT_NOBODY, true );1003 curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 );1004 }1005 1026 1006 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );1007 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 );1008 curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] );1009 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );1010 1011 1027 if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) 1012 1028 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 1013 1029