- * @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 &_getTransport( $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_Fopen::test($args) ) {
- $working_transport['fopen'] = new WP_Http_Fopen();
- $blocking_transport[] = &$working_transport['fopen'];
- } else if ( true === WP_Http_Fsockopen::test($args) ) {
- $working_transport['fsockopen'] = new WP_Http_Fsockopen();
- $blocking_transport[] = &$working_transport['fsockopen'];
- }
-
- foreach ( array('curl', 'streams', 'fopen', 'fsockopen', 'exthttp') as $transport ) {
- if ( isset($working_transport[$transport]) )
- $nonblocking_transport[] = &$working_transport[$transport];
- }
- }
-
- do_action( 'http_transport_get_debug', $working_transport, $blocking_transport, $nonblocking_transport );
-
- if ( isset($args['blocking']) && !$args['blocking'] )
- return $nonblocking_transport;
- else
- return $blocking_transport;
- }
-
- /**
- * 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;
- }
-
- /**
- * Send a HTTP request to a URI.
- *
- * The body and headers are part of the arguments. The 'body' argument is for the body and will
- * accept either a string or an array. The 'headers' argument should be an array, but a string
- * is acceptable. If the 'body' argument is an array, then it will automatically be escaped
- * using http_build_query().
- *
- * The only URI that are supported in the HTTP Transport implementation are the HTTP and HTTPS
- * protocols. HTTP and HTTPS are assumed so the server might not know how to handle the send
- * headers. Other protocols are unsupported and most likely will fail.
- *
- * The defaults are 'method', 'timeout', 'redirection', 'httpversion', 'blocking' and
- * 'user-agent'.
- *
- * Accepted 'method' values are 'GET', 'POST', and 'HEAD', some transports technically allow
- * others, but should not be assumed. The 'timeout' is used to sent how long the connection
- * should stay open before failing when no response. 'redirection' is used to track how many
- * redirects were taken and used to sent the amount for other transports, but not all transports
- * accept setting that value.
- *
- * The 'httpversion' option is used to sent the HTTP version and accepted values are '1.0', and
- * '1.1' and should be a string. Version 1.1 is not supported, because of chunk response. The
- * 'user-agent' option is the user-agent and is used to replace the default user-agent, which is
- * 'WordPress/WP_Version', where WP_Version is the value from $wp_version.
- *
- * 'blocking' is the default, which is used to tell the transport, whether it should halt PHP
- * while it performs the request or continue regardless. Actually, that isn't entirely correct.
- * Blocking mode really just means whether the fread should just pull what it can whenever it
- * gets bytes or if it should wait until it has enough in the buffer to read or finishes reading
- * the entire content. It doesn't actually always mean that PHP will continue going after making
- * the request.