<!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>[17534] trunk: Remove PHP4 based WP_Http_Fopen class.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17534">17534</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2011-03-23 11:35:41 +0000 (Wed, 23 Mar 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove PHP4 based WP_Http_Fopen class. Props sivel for initial patch. See <a href="http://trac.wordpress.org/ticket/16917">#16917</a> Fixes <a href="http://trac.wordpress.org/ticket/13915">#13915</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesimageeditphp">trunk/wp-admin/includes/image-edit.php</a></li>
<li><a href="#trunkwpincludesclasshttpphp">trunk/wp-includes/class-http.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesimageeditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/image-edit.php (17533 => 17534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/image-edit.php        2011-03-22 20:43:16 UTC (rev 17533)
+++ trunk/wp-admin/includes/image-edit.php        2011-03-23 11:35:41 UTC (rev 17534)
</span><span class="lines">@@ -204,7 +204,7 @@
</span><span class="cx">                 if ( 'full' != $size &amp;&amp; ( $data = image_get_intermediate_size($post_id, $size) ) ) {
</span><span class="cx">                         $filepath = apply_filters('load_image_to_edit_filesystempath', path_join( dirname($filepath), $data['file'] ), $post_id, $size);
</span><span class="cx">                 }
</span><del>-        } elseif ( WP_Http_Fopen::test() ) {
</del><ins>+        } elseif ( function_exists('fopen') &amp;&amp; function_exists('ini_get') &amp;&amp; true == ini_get('allow_url_fopen') ) {
</ins><span class="cx">                 $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($post_id) , $post_id, $size);
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesclasshttpphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-http.php (17533 => 17534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-http.php        2011-03-22 20:43:16 UTC (rev 17533)
+++ trunk/wp-includes/class-http.php        2011-03-23 11:35:41 UTC (rev 17534)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">          * Tests all of the objects and returns the object that passes. Also caches that object to be
</span><span class="cx">          * used later.
</span><span class="cx">          *
</span><del>-         * The order for the GET/HEAD requests are HTTP Extension, cURL, Streams, Fopen, and finally
</del><ins>+         * The order for the GET/HEAD requests are HTTP Extension, cURL, Streams, and finally
</ins><span class="cx">          * Fsockopen. fsockopen() is used last, because it has the most overhead in its implementation.
</span><span class="cx">          * There isn't any real way around it, since redirects have to be supported, much the same way
</span><span class="cx">          * the other transports also handle redirects.
</span><span class="lines">@@ -98,15 +98,12 @@
</span><span class="cx">                         } else if ( true === WP_Http_Streams::test($args) ) {
</span><span class="cx">                                 $working_transport['streams'] = new WP_Http_Streams();
</span><span class="cx">                                 $blocking_transport[] = &amp;$working_transport['streams'];
</span><del>-                        } else if ( true === WP_Http_Fopen::test($args) ) {
-                                $working_transport['fopen'] = new WP_Http_Fopen();
-                                $blocking_transport[] = &amp;$working_transport['fopen'];
</del><span class="cx">                         } else if ( true === WP_Http_Fsockopen::test($args) ) {
</span><span class="cx">                                 $working_transport['fsockopen'] = new WP_Http_Fsockopen();
</span><span class="cx">                                 $blocking_transport[] = &amp;$working_transport['fsockopen'];
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        foreach ( array('curl', 'streams', 'fopen', 'fsockopen', 'exthttp') as $transport ) {
</del><ins>+                        foreach ( array('curl', 'streams', 'fsockopen', 'exthttp') as $transport ) {
</ins><span class="cx">                                 if ( isset($working_transport[$transport]) )
</span><span class="cx">                                         $nonblocking_transport[] = &amp;$working_transport[$transport];
</span><span class="cx">                         }
</span><span class="lines">@@ -125,9 +122,7 @@
</span><span class="cx">          *
</span><span class="cx">          * Tests all of the objects and returns the object that passes. Also caches
</span><span class="cx">          * that object to be used later. This is for posting content to a URL and
</span><del>-         * 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.
</del><ins>+         * is used when there is a body.
</ins><span class="cx">          *
</span><span class="cx">          * @since 2.7.0
</span><span class="cx">          * @access private
</span><span class="lines">@@ -807,155 +802,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * HTTP request method uses fopen function to retrieve the url.
- *
- * Requires PHP version greater than 4.3.0 for stream support. Does not allow for $context support,
- * but should still be okay, to write the headers, before getting the response. Also requires that
- * 'allow_url_fopen' to be enabled.
- *
- * @package WordPress
- * @subpackage HTTP
- * @since 2.7.0
- */
-class WP_Http_Fopen {
-        /**
-         * Send a HTTP request to a URI using fopen().
-         *
-         * This transport does not support sending of headers and body, therefore should not be used in
-         * the instances, where there is a body and headers.
-         *
-         * Notes: Does not support non-blocking mode. Ignores 'redirection' option.
-         *
-         * @see WP_Http::retrieve For default options descriptions.
-         *
-         * @access public
-         * @since 2.7.0
-         *
-         * @param string $url URI resource.
-         * @param str|array $args Optional. Override the defaults.
-         * @return array 'headers', 'body', 'cookies' and 'response' keys.
-         */
-        function request($url, $args = array()) {
-                $defaults = array(
-                        'method' =&gt; 'GET', 'timeout' =&gt; 5,
-                        'redirection' =&gt; 5, 'httpversion' =&gt; '1.0',
-                        'blocking' =&gt; true,
-                        'headers' =&gt; array(), 'body' =&gt; null, 'cookies' =&gt; array()
-                );
-
-                $r = wp_parse_args( $args, $defaults );
-
-                $arrURL = parse_url($url);
-
-                if ( false === $arrURL )
-                        return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
-
-                if ( 'http' != $arrURL['scheme'] &amp;&amp; 'https' != $arrURL['scheme'] )
-                        $url = str_replace($arrURL['scheme'], 'http', $url);
-
-                if ( is_null( $r['headers'] ) )
-                        $r['headers'] = array();
-
-                if ( is_string($r['headers']) ) {
-                        $processedHeaders = WP_Http::processHeaders($r['headers']);
-                        $r['headers'] = $processedHeaders['headers'];
-                }
-
-                $initial_user_agent = ini_get('user_agent');
-
-                if ( !empty($r['headers']) &amp;&amp; is_array($r['headers']) ) {
-                        $user_agent_extra_headers = '';
-                        foreach ( $r['headers'] as $header =&gt; $value )
-                                $user_agent_extra_headers .= &quot;\r\n$header: $value&quot;;
-                        @ini_set('user_agent', $r['user-agent'] . $user_agent_extra_headers);
-                } else {
-                        @ini_set('user_agent', $r['user-agent']);
-                }
-
-                if ( !WP_DEBUG )
-                        $handle = @fopen($url, 'r');
-                else
-                        $handle = fopen($url, 'r');
-
-                if (! $handle)
-                        return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
-
-                $timeout = (int) floor( $r['timeout'] );
-                $utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000;
-                stream_set_timeout( $handle, $timeout, $utimeout );
-
-                if ( ! $r['blocking'] ) {
-                        fclose($handle);
-                        @ini_set('user_agent', $initial_user_agent); //Clean up any extra headers added
-                        return array( 'headers' =&gt; array(), 'body' =&gt; '', 'response' =&gt; array('code' =&gt; false, 'message' =&gt; false), 'cookies' =&gt; array() );
-                }
-
-                $strResponse = '';
-                while ( ! feof($handle) )
-                        $strResponse .= fread($handle, 4096);
-
-                if ( function_exists('stream_get_meta_data') ) {
-                        $meta = stream_get_meta_data($handle);
-
-                        $theHeaders = $meta['wrapper_data'];
-                        if ( isset( $meta['wrapper_data']['headers'] ) )
-                                $theHeaders = $meta['wrapper_data']['headers'];
-                } else {
-                        //$http_response_header is a PHP reserved variable which is set in the current-scope when using the HTTP Wrapper
-                        //see http://php.oregonstate.edu/manual/en/reserved.variables.httpresponseheader.php
-                        $theHeaders = $http_response_header;
-                }
-
-                fclose($handle);
-
-                @ini_set('user_agent', $initial_user_agent); //Clean up any extra headers added
-
-                $processedHeaders = WP_Http::processHeaders($theHeaders);
-
-                if ( ! empty( $strResponse ) &amp;&amp; isset( $processedHeaders['headers']['transfer-encoding'] ) &amp;&amp; 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
-                        $strResponse = WP_Http::chunkTransferDecode($strResponse);
-
-                if ( true === $r['decompress'] &amp;&amp; true === WP_Http_Encoding::should_decode($processedHeaders['headers']) )
-                        $strResponse = WP_Http_Encoding::decompress( $strResponse );
-
-                return array('headers' =&gt; $processedHeaders['headers'], 'body' =&gt; $strResponse, 'response' =&gt; $processedHeaders['response'], 'cookies' =&gt; $processedHeaders['cookies']);
-        }
-
-        /**
-         * Whether this class can be used for retrieving an URL.
-         *
-         * @since 2.7.0
-         * @static
-         * @return boolean False means this class can not be used, true means it can.
-         */
-        function test($args = array()) {
-                if ( ! function_exists('fopen') || (function_exists('ini_get') &amp;&amp; true != ini_get('allow_url_fopen')) )
-                        return false;
-
-                if ( isset($args['method']) &amp;&amp; 'HEAD' == $args['method'] ) //This transport cannot make a HEAD request
-                        return false;
-
-                $use = true;
-                //PHP does not verify SSL certs, We can only make a request via this transports if SSL Verification is turned off.
-                $is_ssl = isset($args['ssl']) &amp;&amp; $args['ssl'];
-                if ( $is_ssl ) {
-                        $is_local = isset($args['local']) &amp;&amp; $args['local'];
-                        $ssl_verify = isset($args['sslverify']) &amp;&amp; $args['sslverify'];
-                        if ( $is_local &amp;&amp; true != apply_filters('https_local_ssl_verify', true) )
-                                $use = true;
-                        elseif ( !$is_local &amp;&amp; true != apply_filters('https_ssl_verify', true) )
-                                $use = true;
-                        elseif ( !$ssl_verify )
-                                $use = true;
-                        else
-                                $use = false;
-                }
-
-                return apply_filters('use_fopen_transport', $use, $args);
-        }
-}
-
-/**
</del><span class="cx">  * HTTP request method uses Streams to retrieve the url.
</span><span class="cx">  *
</span><span class="cx">  * Requires PHP 5.0+ and uses fopen with stream context. Requires that 'allow_url_fopen' PHP setting
</span></span></pre>
</div>
</div>

</body>
</html>