Ticket #20219: class-http.php.2.diff
File class-http.php.2.diff, 2.7 KB (added by , 13 years ago) |
---|
-
C:/Users/andyc/Documents/My
1042 1042 curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( $ssl_verify === true ) ? 2 : false ); 1043 1043 curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify ); 1044 1044 curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); 1045 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );1046 1045 1047 1046 switch ( $r['method'] ) { 1048 1047 case 'HEAD': … … 1074 1073 curl_setopt( $handle, CURLOPT_FILE, $stream_handle ); 1075 1074 } 1076 1075 1077 // The option doesn't work with safe mode or when open_basedir is set.1076 // The curl follow location option doesn't work with safe mode or when open_basedir is set. 1078 1077 if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 0 !== $r['_redirection'] ) 1079 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 1078 $autoredirect = true; 1079 1080 if ($autoredirect) { 1081 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 1082 curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); 1083 } 1080 1084 1081 1085 if ( !empty( $r['headers'] ) ) { 1082 1086 // cURL expects full header strings in each element … … 1110 1114 if ( strlen($theResponse) > 0 && ! is_bool( $theResponse ) ) // is_bool: when using $args['stream'], curl_exec will return (bool)true 1111 1115 $theBody = $theResponse; 1112 1116 1113 // If no response, and It's not a HEAD request with valid headers returned 1114 if ( 0 == strlen($theResponse) && ('HEAD' != $args['method'] || empty($this->headers)) ) { 1115 if ( $curl_error = curl_error($handle) ) 1116 return new WP_Error('http_request_failed', $curl_error); 1117 if ( $curl_error = curl_error($handle) ) 1118 return new WP_Error('http_request_failed', $curl_error); 1119 1120 // Handle too many redirects with Curl auto redirect 1121 if ($autoredirect && 0 == strlen($theResponse) && ('HEAD' != $args['method'] || empty($this->headers)) ) { 1117 1122 if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) ) 1118 1123 return new WP_Error('http_request_failed', __('Too many redirects.')); 1119 1124 } … … 1130 1135 fclose( $stream_handle ); 1131 1136 1132 1137 // See #11305 - When running under safe mode, redirection is disabled above. Handle it manually. 1133 if ( ! empty( $theHeaders['headers']['location'] ) && ( ini_get( 'safe_mode' ) || ini_get( 'open_basedir' ) ) && 0 !== $r['_redirection']) {1138 if ( ! empty( $theHeaders['headers']['location'] ) && !$autoredirect ) { 1134 1139 if ( $r['redirection']-- > 0 ) { 1135 1140 return $this->request( $theHeaders['headers']['location'], $r ); 1136 1141 } else {