Changeset 8533
- Timestamp:
- 08/04/2008 04:28:12 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/http.php
r8528 r8533 89 89 90 90 if ( is_null($working_transport) ) { 91 if ( true === WP_Http_ExtHttp::test() )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();97 else if ( true === WP_Http_Fopen::test() )98 $working_transport = new WP_Http_Fopen();99 else if ( true === WP_Http_Fsockopen::test() )100 $working_transport = new WP_Http_Fsockopen();91 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) 92 $working_transport[] = new WP_Http_ExtHttp(); 93 else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) 94 $working_transport[] = new WP_Http_Curl(); 95 else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) 96 $working_transport[] = new WP_Http_Streams(); 97 else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) 98 $working_transport[] = new WP_Http_Fopen(); 99 else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) 100 $working_transport[] = new WP_Http_Fsockopen(); 101 101 } 102 102 … … 122 122 123 123 if ( is_null($working_transport) ) { 124 if ( true === WP_Http_ExtHttp::test() )125 $working_transport = new WP_Http_ExtHttp();126 else if ( true === WP_Http_Streams::test() )127 $working_transport = new WP_Http_Streams();128 else if ( true === WP_Http_Fsockopen::test() )129 $working_transport = new WP_Http_Fsockopen();124 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) 125 $working_transport[] = new WP_Http_ExtHttp(); 126 else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) 127 $working_transport[] = new WP_Http_Streams(); 128 else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) 129 $working_transport[] = new WP_Http_Fsockopen(); 130 130 } 131 131 … … 171 171 * @param str|array $args Optional. Override the defaults. 172 172 * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized. 173 * @param string $body Optional. The body that should be sent. Expected to be alreadyprocessed.173 * @param string $body Optional. The body that should be sent. Will be automatically escaped and processed. 174 174 * @return boolean 175 175 */ … … 178 178 179 179 $defaults = array( 180 'method' => 'GET', 'timeout' => 3,180 'method' => 'GET', 'timeout' => apply_filters('http_request_timeout', 3), 181 181 'redirection' => 5, 'httpversion' => '1.0', 182 182 'user-agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version ), … … 196 196 $headers['user-agent'] = $r['user-agent']; 197 197 198 if ( is_null($body) ) 199 $transport = WP_Http::_getTransport(); 200 else 201 $transport = WP_Http::_postTransport(); 202 203 return $transport->request($url, $r, $headers, $body); 198 if ( is_null($body) ) { 199 if ( ! is_string($body) ) 200 $body = http_build_query($body); 201 202 $transports = WP_Http::_getTransport(); 203 } else 204 $transports = WP_Http::_postTransport(); 205 206 $response = array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') ); 207 foreach( (array) $transports as $transport ) { 208 $response = $transport->request($url, $r, $headers, $body); 209 210 if( !is_wp_error($response) ) 211 break; 212 } 213 214 return $response; 204 215 } 205 216 … … 415 426 $error_reporting = error_reporting(0); 416 427 417 $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, apply_filters('http_request_timeout', absint($r['timeout']) ));428 $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); 418 429 419 430 if ( false === $handle ) … … 539 550 540 551 if ( function_exists('stream_set_timeout') ) 541 stream_set_timeout($handle, apply_filters('http_request_timeout', $r['timeout']));552 stream_set_timeout($handle, $r['timeout'] ); 542 553 543 554 if ( ! $r['blocking'] ) { … … 613 624 $r = wp_parse_args( $args, $defaults ); 614 625 626 if ( isset($headers['User-Agent']) ) { 627 $r['user-agent'] = $headers['User-Agent']; 628 unset($headers['User-Agent']); 629 } else if( isset($headers['user-agent']) ) { 630 $r['user-agent'] = $headers['user-agent']; 631 unset($headers['user-agent']); 632 } else { 633 $r['user-agent'] = apply_filters('http_headers_useragent', 'WordPress/' . $wp_version ); 634 } 635 615 636 $arrURL = parse_url($url); 616 637 … … 621 642 array( 622 643 'method' => strtoupper($r['method']), 623 'user-agent' => $ headers['User-Agent'],644 'user-agent' => $r['user-agent'], 624 645 'max_redirects' => $r['redirection'], 625 646 'protocol_version' => (float) $r['httpversion'], … … 629 650 ); 630 651 652 var_dump($arrContext); 631 653 if ( ! is_null($body) ) 632 654 $arrContext['http']['content'] = $body; … … 639 661 return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); 640 662 641 stream_set_timeout($handle, apply_filters('http_request_stream_timeout', $r['timeout']));663 stream_set_timeout($handle, $r['timeout'] ); 642 664 643 665 if ( ! $r['blocking'] ) {
Note: See TracChangeset
for help on using the changeset viewer.