Changeset 9572
- Timestamp:
- 11/08/2008 10:35:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/http.php
r9188 r9572 85 85 * @access private 86 86 * 87 * @param array $args Request args, default us an empty array 87 88 * @return object|null Null if no transports are available, HTTP transport object. 88 89 */ 89 function &_getTransport( ) {90 static $working_transport ;90 function &_getTransport( $args = array() ) { 91 static $working_transport, $blocking_transport, $nonblocking_transport; 91 92 92 93 if ( is_null($working_transport) ) { 93 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) 94 $working_transport[] = new WP_Http_ExtHttp(); 95 else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) 96 $working_transport[] = new WP_Http_Curl(); 97 else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) 98 $working_transport[] = new WP_Http_Streams(); 99 else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) 100 $working_transport[] = new WP_Http_Fopen(); 101 else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) 102 $working_transport[] = new WP_Http_Fsockopen(); 103 } 104 105 return $working_transport; 94 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { 95 $working_transport['exthttp'] = new WP_Http_ExtHttp(); 96 $blocking_transport[] = &$working_transport['exthttp']; 97 } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { 98 $working_transport['curl'] = new WP_Http_Curl(); 99 $blocking_transport[] = &$working_transport['curl']; 100 } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { 101 $working_transport['streams'] = new WP_Http_Streams(); 102 $blocking_transport[] = &$working_transport['streams']; 103 } else if ( true === WP_Http_Fopen::test() && apply_filters('use_fopen_transport', true) ) { 104 $working_transport['fopen'] = new WP_Http_Fopen(); 105 $blocking_transport[] = &$working_transport['fopen']; 106 } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { 107 $working_transport['fsockopen'] = new WP_Http_Fsockopen(); 108 $blocking_transport[] = &$working_transport['fsockopen']; 109 } 110 111 foreach ( array('curl', 'streams', 'fopen', 'fsockopen', 'exthttp') as $transport ) { 112 if ( isset($working_transport[$transport]) ) 113 $nonblocking_transport[] = &$working_transport[$transport]; 114 } 115 } 116 117 if ( isset($args['blocking']) && !$args['blocking'] ) 118 return $nonblocking_transport; 119 else 120 return $blocking_transport; 106 121 } 107 122 … … 118 133 * @access private 119 134 * 135 * @param array $args Request args, default us an empty array 120 136 * @return object|null Null if no transports are available, HTTP transport object. 121 137 */ 122 function &_postTransport( ) {123 static $working_transport ;138 function &_postTransport( $args = array() ) { 139 static $working_transport, $blocking_transport, $nonblocking_transport; 124 140 125 141 if ( is_null($working_transport) ) { 126 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) 142 if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { 127 143 $working_transport[] = new WP_Http_ExtHttp(); 128 else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) 144 $blocking_transport[] = &$working_transport['exthttp']; 145 } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { 129 146 $working_transport[] = new WP_Http_Streams(); 130 else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) 147 $blocking_transport[] = &$working_transport['streams']; 148 } else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) ) { 131 149 $working_transport[] = new WP_Http_Fsockopen(); 132 } 133 134 return $working_transport; 150 $blocking_transport[] = &$working_transport['fsockopen']; 151 } 152 153 foreach ( array('streams', 'fsockopen', 'exthttp') as $transport ) { 154 if ( isset($working_transport[$transport]) ) 155 $nonblocking_transport[] = &$working_transport[$transport]; 156 } 157 } 158 159 if ( isset($args['blocking']) && !$args['blocking'] ) 160 return $nonblocking_transport; 161 else 162 return $blocking_transport; 135 163 } 136 164 … … 215 243 216 244 if ( is_null($r['body']) ) { 217 $transports = WP_Http::_getTransport( );245 $transports = WP_Http::_getTransport($r); 218 246 } else { 219 247 if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) { … … 223 251 } 224 252 225 $transports = WP_Http::_postTransport( );253 $transports = WP_Http::_postTransport($r); 226 254 } 227 255
Note: See TracChangeset
for help on using the changeset viewer.