<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[17659] trunk/wp-includes/class-http.php:
Remove support for the PHP HTTP Extension from WP_HTTP.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17659">17659</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2011-04-19 04:22:59 +0000 (Tue, 19 Apr 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Remove support for the PHP HTTP Extension from WP_HTTP. The PHP HTTP Extension is a wrapper around libcurl and fopen() providing limited configuration and is supported on a minority of servers due to its non-default inclusion. Props sivel. Fixes @16978</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesclasshttpphp">trunk/wp-includes/class-http.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesclasshttpphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-http.php (17658 => 17659)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-http.php        2011-04-18 22:03:34 UTC (rev 17658)
+++ trunk/wp-includes/class-http.php        2011-04-19 04:22:59 UTC (rev 17659)
</span><span class="lines">@@ -201,9 +201,8 @@
</span><span class="cx">          * Tests each transport in order to find a transport which matches the request arguements.
</span><span class="cx">          * Also caches the transport instance to be used later.
</span><span class="cx">          *
</span><del>-         * The order for blocking requests is HTTP Extension, cURL, Streams, and finally Fsockopen.
-         * The order for non-blocking requests is cURL, Streams, Fsockopen() and finally, HTTP Extension.
-         * The HTTP Extension does not support non-blocking requests, but is included as a final resort.
</del><ins>+         * The order for blocking requests is cURL, Streams, and finally Fsockopen.
+         * The order for non-blocking requests is cURL, Streams and Fsockopen().
</ins><span class="cx">          *
</span><span class="cx">          * There are currently issues with "localhost" not resolving correctly with DNS. This may cause
</span><span class="cx">          * an error "failed to open stream: A connection attempt failed because the connected party did
</span><span class="lines">@@ -220,9 +219,7 @@
</span><span class="cx">         private function _dispatch_request($url, $args) {
</span><span class="cx">                 static $transports = array();
</span><span class="cx">
</span><del>-                $request_order = isset($args['blocking']) && !$args['blocking'] ?
-                                                        array('curl', 'streams', 'fsockopen', 'exthttp') : // non-blocking order
-                                                        array('exthttp', 'curl', 'streams', 'fsockopen'); // blocking order
</del><ins>+                $request_order = array('curl', 'streams', 'fsockopen');
</ins><span class="cx">
</span><span class="cx">                 // Loop over each transport on each HTTP request looking for one which will serve this requests needs
</span><span class="cx">                 foreach ( $request_order as $transport ) {
</span><span class="lines">@@ -702,7 +699,7 @@
</span><span class="cx">
</span><span class="cx">                         fclose( $stream_handle );
</span><span class="cx">
</span><del>-                } else {
</del><ins>+                } else {
</ins><span class="cx">                         while ( ! feof($handle) )
</span><span class="cx">                                 $strResponse .= fread( $handle, 4096 );
</span><span class="cx">
</span><span class="lines">@@ -903,7 +900,7 @@
</span><span class="cx">                 else
</span><span class="cx">                         $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
</span><span class="cx">
</span><del>-                // Streams does not provide an error code which we can use to see why the request stream stoped.
</del><ins>+                // Streams does not provide an error code which we can use to see why the request stream stoped.
</ins><span class="cx">                 // We can however test to see if a location header is present and return based on that.
</span><span class="cx">                 if ( isset($processedHeaders['headers']['location']) && 0 !== $args['_redirection'] )
</span><span class="cx">                         return new WP_Error('http_request_failed', __('Too many redirects.'));
</span><span class="lines">@@ -943,170 +940,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * HTTP request method uses HTTP extension to retrieve the url.
- *
- * Requires the HTTP extension to be installed. This would be the preferred transport since it can
- * handle a lot of the problems that forces the others to use the HTTP version 1.0. Even if PHP 5.2+
- * is being used, it doesn't mean that the HTTP extension will be enabled.
- *
- * @package WordPress
- * @subpackage HTTP
- * @since 2.7.0
- */
-class WP_Http_ExtHttp {
-        /**
-         * Send a HTTP request to a URI using HTTP extension.
-         *
-         * Does not support non-blocking.
-         *
-         * @access public
-         * @since 2.7
-         *
-         * @param string $url
-         * @param str|array $args Optional. Override the defaults.
-         * @return array 'headers', 'body', 'cookies' and 'response' keys.
-         */
-        function request($url, $args = array()) {
-                $defaults = array(
-                        'method' => 'GET', 'timeout' => 5,
-                        'redirection' => 5, 'httpversion' => '1.0',
-                        'blocking' => true,
-                        'headers' => array(), 'body' => null, 'cookies' => array()
-                );
-
-                $r = wp_parse_args( $args, $defaults );
-
-                if ( isset($r['headers']['User-Agent']) ) {
-                        $r['user-agent'] = $r['headers']['User-Agent'];
-                        unset($r['headers']['User-Agent']);
-                } else if ( isset($r['headers']['user-agent']) ) {
-                        $r['user-agent'] = $r['headers']['user-agent'];
-                        unset($r['headers']['user-agent']);
-                }
-
-                // Construct Cookie: header if any cookies are set
-                WP_Http::buildCookieHeader( $r );
-
-                switch ( $r['method'] ) {
-                        case 'POST':
-                                $r['method'] = HTTP_METH_POST;
-                                break;
-                        case 'HEAD':
-                                $r['method'] = HTTP_METH_HEAD;
-                                break;
-                        case 'PUT':
-                                $r['method'] = HTTP_METH_PUT;
-                                break;
-                        case 'GET':
-                        default:
-                                $r['method'] = HTTP_METH_GET;
-                }
-
-                $arrURL = parse_url($url);
-
-                if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
-                        $url = preg_replace('|^' . preg_quote($arrURL['scheme'], '|') . '|', 'http', $url);
-
-                $is_local = isset($args['local']) && $args['local'];
-                $ssl_verify = isset($args['sslverify']) && $args['sslverify'];
-                if ( $is_local )
-                        $ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify);
-                elseif ( ! $is_local )
-                        $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify);
-
-                $r['timeout'] = (int) ceil( $r['timeout'] );
-
-                $options = array(
-                        'timeout' => $r['timeout'],
-                        'connecttimeout' => $r['timeout'],
-                        'redirect' => $r['redirection'],
-                        'useragent' => $r['user-agent'],
-                        'headers' => $r['headers'],
-                        'ssl' => array(
-                                'verifypeer' => $ssl_verify,
-                                'verifyhost' => $ssl_verify
-                        )
-                );
-
-                // The HTTP extensions offers really easy proxy support.
-                $proxy = new WP_HTTP_Proxy();
-
-                if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
-                        $options['proxyhost'] = $proxy->host();
-                        $options['proxyport'] = $proxy->port();
-                        $options['proxytype'] = HTTP_PROXY_HTTP;
-
-                        if ( $proxy->use_authentication() ) {
-                                $options['proxyauth'] = $proxy->authentication();
-                                $options['proxyauthtype'] = HTTP_AUTH_ANY;
-                        }
-                }
-
-                if ( !WP_DEBUG ) //Emits warning level notices for max redirects and timeouts
-                        $strResponse = @http_request($r['method'], $url, $r['body'], $options, $info);
-                else
-                        $strResponse = http_request($r['method'], $url, $r['body'], $options, $info); //Emits warning level notices for max redirects and timeouts
-
-                // Error may still be set, Response may return headers or partial document, and error
-                // contains a reason the request was aborted, eg, timeout expired or max-redirects reached.
-                if ( false === $strResponse || ! empty($info['error']) )
-                        return new WP_Error('http_request_failed', $info['response_code'] . ': ' . $info['error']);
-
-                if ( ! $r['blocking'] )
-                        return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
-
-                $headers_body = WP_HTTP::processResponse($strResponse);
-                $theHeaders = $headers_body['headers'];
-                $theBody = $headers_body['body'];
-                unset($headers_body);
-
-                $theHeaders = WP_Http::processHeaders($theHeaders);
-
-                if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) {
-                        if ( !WP_DEBUG )
-                                $theBody = @http_chunked_decode($theBody);
-                        else
-                                $theBody = http_chunked_decode($theBody);
-                }
-
-                if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) )
-                        $theBody = http_inflate( $theBody );
-
-                if ( $r['stream'] ) {
-                        if ( !WP_DEBUG )
-                                $stream_handle = @fopen( $r['filename'], 'w+' );
-                        else
-                                $stream_handle = fopen( $r['filename'], 'w+' );
-
-                        if ( ! $stream_handle )
-                                return new WP_Error( 'http_request_failed', sprintf( __( 'Could not open handle for fopen() to %s' ), $r['filename'] ) );
-
-                        fwrite( $stream_handle, $theBody );
-                        fclose( $stream_handle );
-                        $theBody = '';
-                }
-
-                $theResponse = array();
-                $theResponse['code'] = $info['response_code'];
-                $theResponse['message'] = get_status_header_desc($info['response_code']);
-
-                return array( 'headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse, 'cookies' => $theHeaders['cookies'], 'filename' => $r['filename'] );
-        }
-
-        /**
-         * Whether this class can be used for retrieving an URL.
-         *
-         * @static
-         * @since 2.7.0
-         *
-         * @return boolean False means this class can not be used, true means it can.
-         */
-        function test($args = array()) {
-                return apply_filters('use_http_extension_transport', function_exists('http_request'), $args );
-        }
-}
-
-/**
</del><span class="cx"> * HTTP request method uses Curl extension to retrieve the url.
</span><span class="cx"> *
</span><span class="cx"> * Requires the Curl extension to be installed.
</span><span class="lines">@@ -1341,7 +1174,7 @@
</span><span class="cx"> * constants.
</span><span class="cx"> *
</span><span class="cx"> * Please note that only BASIC authentication is supported by most transports.
</span><del>- * cURL and the PHP HTTP Extension MAY support more methods (such as NTLM authentication) depending on your environment.
</del><ins>+ * cURL MAY support more methods (such as NTLM authentication) depending on your environment.
</ins><span class="cx"> *
</span><span class="cx"> * The constants are as follows:
</span><span class="cx"> * <ol>
</span></span></pre>
</div>
</div>
</body>
</html>