Ticket #4779: 4779.r8522.2.diff
| File 4779.r8522.2.diff, 3.9 KB (added by santosj, 4 years ago) |
|---|
-
http.php
88 88 static $working_transport; 89 89 90 90 if ( is_null($working_transport) ) { 91 if ( true === WP_Http_Streams::test() ) 92 $working_transport = new WP_Http_Streams(); 93 else if ( true === WP_Http_ExtHttp::test() ) 91 if ( true === WP_Http_ExtHttp::test() ) 94 92 $working_transport = new WP_Http_ExtHttp(); 93 else if ( true === WP_Http_Curl::test() ) 94 $working_transport = new WP_Http_Curl(); 95 else if ( true === WP_Http_Streams::test() ) 96 $working_transport = new WP_Http_Streams(); 95 97 else if ( true === WP_Http_Fopen::test() ) 96 98 $working_transport = new WP_Http_Fopen(); 97 99 else if ( true === WP_Http_Fsockopen::test() ) … … 119 121 static $working_transport; 120 122 121 123 if ( is_null($working_transport) ) { 122 if ( true === WP_Http_Streams::test() ) 123 $working_transport = new WP_Http_Streams(); 124 else if ( true === WP_Http_ExtHttp::test() ) 124 if ( true === WP_Http_ExtHttp::test() ) 125 125 $working_transport = new WP_Http_ExtHttp(); 126 else if ( true === WP_Http_Streams::test() ) 127 $working_transport = new WP_Http_Streams(); 126 128 else if ( true === WP_Http_Fsockopen::test() ) 127 129 $working_transport = new WP_Http_Fsockopen(); 128 130 } … … 193 195 if ( ! isset($headers['user-agent']) || ! isset($headers['User-Agent']) ) 194 196 $headers['user-agent'] = $r['user-agent']; 195 197 196 if ( is_null($body) || count($headers) > 1)198 if ( is_null($body) ) 197 199 $transport = WP_Http::_getTransport(); 198 200 else 199 201 $transport = WP_Http::_postTransport(); … … 313 315 /** 314 316 * Transform header string into an array. 315 317 * 316 * If an array is given, then it will be immediately passed through with no 317 * changes. This is to prevent overhead in processing headers that don't 318 * need to be processed. That and it is unknown what kind of effect 319 * processing the array will have since there is no checking done on whether 320 * ':' does not exist within the array string. 318 * If an array is given then it is assumed to be raw header data with 319 * numeric keys with the headers as the values. No headers must be passed 320 * that were already processed. 321 321 * 322 * Checking could be added, but it is easier and faster to just passed the323 * array through and assume that it has already been processed.324 *325 322 * @access public 326 323 * @static 327 324 * @since 2.7 … … 330 327 * @return array Processed string headers 331 328 */ 332 329 function processHeaders($headers) { 333 if ( is_ array($headers) )334 return $headers;330 if ( is_string($headers) ) 331 $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) ); 335 332 336 $headers = explode("\n", str_replace(array("\r\n", "\r"), "\n", $headers) );337 338 333 $response = array('code' => 0, 'message' => ''); 339 334 340 335 $newheaders = array(); … … 342 337 if ( empty($tempheader) ) 343 338 continue; 344 339 340 345 341 if ( false === strpos($tempheader, ':') ) { 346 342 list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3); 347 343 $response['code'] = $iResponseCode; … … 560 556 } else { 561 557 $theHeaders = $http_response_header; 562 558 } 563 $processedHeaders = WP_Http::processHeaders($theHeaders);564 559 565 560 fclose($handle); 561 562 $processedHeaders = WP_Http::processHeaders($theHeaders); 563 566 564 return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']); 567 565 } 568 566 … … 762 760 $theHeaders = WP_Http::processHeaders($theHeaders); 763 761 764 762 $theResponse = array(); 765 $theResponse[' response']['code'] = $info['response_code'];766 $theResponse[' response']['message'] = get_status_header_desc($info['response_code']);763 $theResponse['code'] = $info['response_code']; 764 $theResponse['message'] = get_status_header_desc($info['response_code']); 767 765 768 766 return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse); 769 767 }
