Changeset 17551 for trunk/wp-includes/class-http.php
- Timestamp:
- 03/24/2011 05:18:34 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-http.php
r17550 r17551 101 101 ); 102 102 103 104 // Pre-parse for the HEAD checks. 105 $args = wp_parse_args( $args ); 106 107 // By default, Head requests do not cause redirections. 108 if ( isset($args['method']) && 'HEAD' == $args['method'] ) 109 $defaults['redirection'] = 0; 110 103 111 $r = wp_parse_args( $args, $defaults ); 104 112 $r = apply_filters( 'http_request_args', $r, $url ); 113 114 // Certain classes decrement this, store a copy of the original value for loop purposes. 115 $r['_redirection'] = $r['redirection']; 105 116 106 117 // Allow plugins to short-circuit the request … … 665 676 666 677 // If location is found, then assume redirect and redirect to location. 667 if ( 'HEAD' != $r['method'] && isset($arrHeaders['headers']['location'])) {678 if ( isset($arrHeaders['headers']['location']) && 0 !== $r['_redirection'] ) { 668 679 if ( $r['redirection']-- > 0 ) { 669 680 return $this->request($arrHeaders['headers']['location'], $r); … … 801 812 } 802 813 803 if ( 'HEAD' == $r['method'] ) // Disable redirects for HEAD requests804 $arrContext['http']['max_redirects'] = 1;805 806 814 if ( ! empty($r['body'] ) ) 807 815 $arrContext['http']['content'] = $r['body']; … … 837 845 else 838 846 $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']); 847 848 // Streams does not provide an error code which we can use to see why the request stream stoped. 849 // We can however test to see if a location header is present and return based on that. 850 if ( isset($processedHeaders['headers']['location']) && 0 !== $args['_redirection'] ) 851 return new WP_Error('http_request_failed', __('Too many redirects.')); 839 852 840 853 if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] ) … … 950 963 ); 951 964 952 if ( HTTP_METH_HEAD == $r['method'] )953 $options['redirect'] = 0; // Assumption: Docs seem to suggest that this means do not follow. Untested.954 955 965 // The HTTP extensions offers really easy proxy support. 956 966 $proxy = new WP_HTTP_Proxy(); … … 1117 1127 1118 1128 // The option doesn't work with safe mode or when open_basedir is set. 1119 // Disable HEAD when making HEAD requests. 1120 if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 'HEAD' != $r['method'] ) 1129 if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 0 !== $r['_redirection'] ) 1121 1130 curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); 1122 1131 … … 1177 1186 1178 1187 // See #11305 - When running under safe mode, redirection is disabled above. Handle it manually. 1179 if ( !empty($theHeaders['headers']['location']) && (ini_get('safe_mode') || ini_get('open_basedir')) ) {1188 if ( !empty($theHeaders['headers']['location']) && (ini_get('safe_mode') || ini_get('open_basedir')) && 0 !== $r['_redirection'] ) { 1180 1189 if ( $r['redirection']-- > 0 ) { 1181 1190 return $this->request($theHeaders['headers']['location'], $r);
Note: See TracChangeset
for help on using the changeset viewer.