Changeset 9091
- Timestamp:
- 10/06/2008 11:10:22 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/http.php
r8842 r9091 531 531 return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']); 532 532 533 // If the body was chunk encoded, then decode it.534 if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] )535 $process['body'] = WP_Http::chunkTransferDecode($process['body']);536 537 533 // If location is found, then assume redirect and redirect to location. 538 534 if ( isset($arrHeaders['headers']['location']) ) { 539 535 if ( $r['redirection']-- > 0 ) { 540 536 return $this->request($arrHeaders['headers']['location'], $r); 537 } else { 538 return new WP_Error('http_request_failed', __('Too many redirects.')); 541 539 } 542 else 543 return new WP_Error('http_request_failed', __('Too many redirects.')); 544 } 540 } 541 542 // If the body was chunk encoded, then decode it. 543 if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) 544 $process['body'] = WP_Http::chunkTransferDecode($process['body']); 545 545 546 546 return array('headers' => $arrHeaders['headers'], 'body' => $process['body'], 'response' => $arrHeaders['response']); … … 859 859 ); 860 860 861 $strResponse = http_request($r['method'], $url, $r['body'], $options, $info); 862 863 if ( false === $strResponse ) 861 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts 862 $strResponse = @http_request($r['method'], $url, $r['body'], $options, $info); 863 else 864 $strResponse = http_request($r['method'], $url, $r['body'], $options, $info); //Emits warning level notices for max redirects and timeouts 865 866 if ( false === $strResponse || ! empty($info['error']) ) //Error may still be set, Response may return headers or partial document, and error contains a reason the request was aborted, eg, timeout expired or max-redirects reached 864 867 return new WP_Error('http_request_failed', $info['response_code'] . ': ' . $info['error']); 865 868 … … 870 873 $theHeaders = WP_Http::processHeaders($theHeaders); 871 874 872 if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) 873 $theBody = http_chunked_decode($theBody); 875 if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) { 876 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) 877 $theBody = @http_chunked_decode($theBody); 878 else 879 $theBody = http_chunked_decode($theBody); 880 } 874 881 875 882 $theResponse = array(); … … 971 978 $theResponse = curl_exec( $handle ); 972 979 973 list($theHeaders, $theBody) = explode("\r\n\r\n", $theResponse, 2); 974 $theHeaders = WP_Http::processHeaders($theHeaders); 975 976 if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) 977 $theBody = WP_Http::chunkTransferDecode($theBody); 978 980 if ( $theResponse ) { 981 $headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE); 982 $theHeaders = trim( substr($theResponse, 0, $headerLength) ); 983 $theBody = substr( $theResponse, $headerLength ); 984 if ( false !== strrpos($theHeaders, "\r\n\r\n") ) { 985 $headerParts = explode("\r\n\r\n", $theHeaders); 986 $theHeaders = $headerParts[ count($headerParts) -1 ]; 987 } 988 $theHeaders = WP_Http::processHeaders($theHeaders); 989 } else { 990 if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) ) 991 return new WP_Error('http_request_failed', __('Too many redirects.')); 992 $theHeaders = array( 'headers' => array() ); 993 $theBody = ''; 994 } 979 995 $response = array(); 980 996 $response['code'] = curl_getinfo( $handle, CURLINFO_HTTP_CODE );
Note: See TracChangeset
for help on using the changeset viewer.