Changeset 8634
- Timestamp:
- 08/13/2008 05:09:59 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/http.php
r8630 r8634 352 352 * 353 353 * @todo Add support for footer chunked headers. 354 * 354 * @access public 355 * @since 2.7 355 356 * @static 357 * 356 358 * @param string $body Body content 357 359 * @return bool|string|WP_Error False if not chunked encoded. WP_Error on failure. Chunked decoded body on success. … … 363 365 return false; 364 366 365 $hex = '';366 $dec = 0;367 367 $parsedBody = ''; 368 $parsedHeaders = array();368 //$parsedHeaders = array(); Unsupported 369 369 370 370 $done = false; … … 381 381 $chunkLength = strlen( $match[0] ); 382 382 383 if( $body{$length+$chunkLength} == "\n" )384 $length++;385 386 383 $strBody = substr($body, strlen( $match[0] ), $length); 387 384 $parsedBody .= $strBody; 388 $body = str_replace(array($match[0], $strBody), '', $body); 389 390 if( "0" == $body ) { 385 386 $body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n"); 387 388 if( "0" == trim($body) ) { 391 389 $done = true; 392 390 return $parsedBody; // Ignore footer headers. … … 512 510 $arrHeaders = WP_Http::processHeaders($process['headers']); 513 511 514 if ( WP_Http_Fsockopen::is400Response($arrHeaders['response']['code']) ) 512 // Is the response code within the 400 range? 513 if ( (int) $arrHeaders['response']['code'] >= 400 && (int) $arrHeaders['response']['code'] < 500 ) 515 514 return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']); 515 516 // If the body was chunk encoded, then decode it. 517 if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) 518 $process['body'] = WP_Http::chunkTransferDecode($process['body']); 516 519 517 520 // If location is found, then assume redirect and redirect to location. … … 540 543 return false; 541 544 } 542 543 /**544 * Whether response code is in the 400 range.545 *546 * @access public547 * @static548 * @since 2.7549 *550 * @param string $response Response code.551 * @return bool True if 40x Response, false if something else.552 */553 function is400Response($response) {554 if ( is_numeric($response) && (int) substr($response, 0, 1) == 4 )555 return true;556 return false;557 }558 545 } 559 546 … … 640 627 641 628 if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] ) 642 $ theBody= WP_Http::chunkTransferDecode($strResponse);629 $strResponse = WP_Http::chunkTransferDecode($strResponse); 643 630 644 631 return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']); … … 752 739 753 740 if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] ) 754 $ theBody= WP_Http::chunkTransferDecode($strResponse);741 $strResponse = WP_Http::chunkTransferDecode($strResponse); 755 742 756 743 fclose($handle);
Note: See TracChangeset
for help on using the changeset viewer.