Beispiel #1
0
 /**
  * Tests the WordPress HTTP objects for an object to use and returns it.
  *
  * Tests all of the objects and returns the object that passes. Also caches
  * that object to be used later. This is for posting content to a URL and
  * is used when there is a body. The plain Fopen Transport can not be used
  * to send content, but the streams transport can. This is a limitation that
  * is addressed here, by just not including that transport.
  *
  * @since 2.7.0
  * @access private
  *
  * @param array $args Request args, default us an empty array
  * @return object|null Null if no transports are available, HTTP transport object.
  */
 function &_postTransport($args = array())
 {
     static $working_transport, $blocking_transport, $nonblocking_transport;
     if (is_null($working_transport)) {
         if (true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true)) {
             $working_transport['exthttp'] = new WP_Http_ExtHttp();
             $blocking_transport[] =& $working_transport['exthttp'];
         } else {
             if (true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true)) {
                 $working_transport['streams'] = new WP_Http_Streams();
                 $blocking_transport[] =& $working_transport['streams'];
             } else {
                 if (true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true)) {
                     $working_transport['fsockopen'] = new WP_Http_Fsockopen();
                     $blocking_transport[] =& $working_transport['fsockopen'];
                 }
             }
         }
         foreach (array('streams', 'fsockopen', 'exthttp') as $transport) {
             if (isset($working_transport[$transport])) {
                 $nonblocking_transport[] =& $working_transport[$transport];
             }
         }
     }
     if (has_filter('http_transport_post_debug')) {
         do_action('http_transport_post_debug', $working_transport, $blocking_transport, $nonblocking_transport);
     }
     if (isset($args['blocking']) && !$args['blocking']) {
         return $nonblocking_transport;
     } else {
         return $blocking_transport;
     }
 }
Beispiel #2
0
 /**
  * Tests the WordPress HTTP objects for an object to use and returns it.
  *
  * Tests all of the objects and returns the object that passes. Also caches
  * that object to be used later. This is for posting content to a URL and
  * is used when there is a body. The plain Fopen Transport can not be used
  * to send content, but the streams transport can. This is a limitation that
  * is addressed here, by just not including that transport.
  *
  * @since 2.7.0
  * @access private
  *
  * @param array $args Request args, default us an empty array
  * @return object|null Null if no transports are available, HTTP transport object.
  */
 function &_postTransport($args = array())
 {
     static $working_transport, $blocking_transport, $nonblocking_transport;
     if (is_null($working_transport)) {
         if (true === WP_Http_ExtHttp::test($args)) {
             $working_transport['exthttp'] = new WP_Http_ExtHttp();
             $blocking_transport[] =& $working_transport['exthttp'];
         } else {
             if (true === WP_Http_Curl::test($args)) {
                 $working_transport['curl'] = new WP_Http_Curl();
                 $blocking_transport[] =& $working_transport['curl'];
             } else {
                 if (true === WP_Http_Streams::test($args)) {
                     $working_transport['streams'] = new WP_Http_Streams();
                     $blocking_transport[] =& $working_transport['streams'];
                 } else {
                     if (true === WP_Http_Fsockopen::test($args)) {
                         $working_transport['fsockopen'] = new WP_Http_Fsockopen();
                         $blocking_transport[] =& $working_transport['fsockopen'];
                     }
                 }
             }
         }
         foreach (array('curl', 'streams', 'fsockopen', 'exthttp') as $transport) {
             if (isset($working_transport[$transport])) {
                 $nonblocking_transport[] =& $working_transport[$transport];
             }
         }
     }
     do_action('http_transport_post_debug', $working_transport, $blocking_transport, $nonblocking_transport);
     if (isset($args['blocking']) && !$args['blocking']) {
         return $nonblocking_transport;
     } else {
         return $blocking_transport;
     }
 }
 function have_streams($args, $url = NULL)
 {
     return WP_Http_Streams::test($args);
 }