Ticket #10624: 10624.2.diff
| File 10624.2.diff, 2.7 KB (added by , 17 years ago) |
|---|
-
wp-includes/http.php
739 768 return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']); 740 769 741 770 // If location is found, then assume redirect and redirect to location. 742 if ( isset($arrHeaders['headers']['location']) ) {771 if ( 'HEAD' != $r['method'] && isset($arrHeaders['headers']['location']) ) { 743 772 if ( $r['redirection']-- > 0 ) { 744 773 return $this->request($arrHeaders['headers']['location'], $r); 745 774 } else { … … 884 913 if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) ) 885 914 return false; 886 915 916 if ( isset($args['method']) && 'HEAD' == $args['method'] ) //This transport cannot make a HEAD request. 917 return false; 918 887 919 $use = true; 888 920 889 921 //PHP does not verify SSL certs, We can only make a request via this transports if SSL Verification is turned off. … … 980 1012 'protocol_version' => (float) $r['httpversion'], 981 1013 'header' => $strHeaders, 982 1014 'timeout' => $r['timeout'], 1015 'ignore_errors' => true, // Return non-200 requests. 983 1016 'ssl' => array( 984 1017 'verify_peer' => $ssl_verify, 985 1018 'verify_host' => $ssl_verify … … 1001 1034 if ( ! is_null($r['body']) && ! empty($r['body'] ) ) 1002 1035 $arrContext['http']['content'] = $r['body']; 1003 1036 1037 if ( 'HEAD' == $r['method'] ) // Disable redirects for HEAD requests 1038 $arrContext['http']['max_redirects'] = 1; 1039 1004 1040 $context = stream_context_create($arrContext); 1005 1041 1006 1042 if ( !WP_DEBUG ) … … 1008 1044 else 1009 1045 $handle = fopen($url, 'r', false, $context); 1010 1046 1011 if ( ! $handle )1047 if ( ! $handle ) 1012 1048 return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); 1013 1049 1014 1050 $timeout = (int) floor( $r['timeout'] ); … … 1159 1195 ) 1160 1196 ); 1161 1197 1198 if ( HTTP_METH_HEAD == $r['method'] ) 1199 $options['redirect'] = 0; // Assumption: Docs seem to suggest that this means do not follow. Untested. 1200 1162 1201 // The HTTP extensions offers really easy proxy support. 1163 1202 $proxy = new WP_HTTP_Proxy(); 1164 1203 … … 1326 1365 else 1327 1366 curl_setopt( $handle, CURLOPT_HEADER, false ); 1328 1367 1329 // The option doesn't work with safe mode or when open_basedir is set. 1330 if ( !ini_get('safe_mode') && !ini_get('open_basedir') )1368 // The option doesn't work with safe mode or when open_basedir is set. Do not follow for Redirects either. 1369 if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 'HEAD' != $r['method'] ) 1331 1370 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 1332 1371 1333 1372 if ( !empty( $r['headers'] ) ) {