<!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" />
<title>[50108] branches/3.7/tests/phpunit/tests/http: Tests: Use `skipTestOnTimeout()` in more HTTP tests.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50108">50108</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50108","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-01-30 21:29:39 +0000 (Sat, 30 Jan 2021)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Tests: Use `skipTestOnTimeout()` in more HTTP tests.

Adjust it to handle more types of timeouts, e.g. "Resolving timed out", "Connection timed out".

Merges <a href="https://core.trac.wordpress.org/changeset/38757">[38757]</a>, <a href="https://core.trac.wordpress.org/changeset/43511">[43511]</a>, <a href="https://core.trac.wordpress.org/changeset/43512">[43512]</a>, <a href="https://core.trac.wordpress.org/changeset/46682">[46682]</a>, <a href="https://core.trac.wordpress.org/changeset/46996">[46996]</a>, <a href="https://core.trac.wordpress.org/changeset/50105">[50105]</a> to the 3.7 branch.
See <a href="https://core.trac.wordpress.org/ticket/51669">#51669</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches37testsphpunitincludestestcasephp">branches/3.7/tests/phpunit/includes/testcase.php</a></li>
<li><a href="#branches37testsphpunittestshttpbasephp">branches/3.7/tests/phpunit/tests/http/base.php</a></li>
<li><a href="#branches37testsphpunittestshttpfunctionsphp">branches/3.7/tests/phpunit/tests/http/functions.php</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#branches37">branches/3.7/</a></li>
<li><a href="#branches37src">branches/3.7/src/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/3.7
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/3.7 2021-01-30 21:28:58 UTC (rev 50107)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/3.7  2021-01-30 21:29:39 UTC (rev 50108)
</ins><a id="branches37"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/3.7</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/4.9:42434,49653
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.0:43988,43994,44014,44017,44047
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.5:49373-49379,49381
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:25882-25884,25889,25891,25893,25895,25897,25899,25902,25915,25921,25923,25925,25929,25933,25954,25956,25974-25975,25977,25986,26014,26016-26017,26087,26091,26095,26148-26149,26186,26252,26304-26305,26307,26318,26448-26449,26512,26705,26734,26782,26871,26909-26910,26927,26940,27086,27168,27385,27872,27905-27906,27928,27964,27975,27990,28053,28113,28129,28799,28873,28943,28961,28964,28966-28967,29120,29251,29327,29378,29381-29382,29397,29404,29503,29631,29783,29860,29869,29954,30001,30282,30285,30289-30291,30337,30412,30417,30425,30430,30438,30443,30458,30466,30513-30514,30516-30521,30524,30526,30529-30530,31253-31254,31257-31259,31622,33124,33142,36083,36435,37651,38524,39645,39659,39759,39795,39807-39808,39831,39850,39956,40148,40169,40183,40241,40255,40257,40259,40269,40271,40400,40446,40449,40457,40538,40604,40677,40692,40704,40723,40736,40833,41082,41303,41306,41393,41398,41457
 ,41470,41483,41496,41522,41662,42056,42119-42120,42258-42261,42424,42433,42892-42893,44021,44048,44842,44993,45936,45971,45997,46474-46478,46483,46485,46895,47341,47947-47951,48241,49380,49382-49388,49876
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:25882-25884,25889,25891,25893,25895,25897,25899,25902,25915,25921,25923,25925,25929,25933,25954,25956,25974-25975,25977,25986,26014,26016-26017,26087,26091,26095,26148-26149,26186,26252,26304-26305,26307,26318,26448-26449,26512,26705,26734,26782,26871,26909-26910,26927,26940,27086,27168,27385,27872,27905-27906,27928,27964,27975,27990,28053,28113,28129,28799,28873,28943,28961,28964,28966-28967,29120,29251,29327,29378,29381-29382,29397,29404,29503,29631,29783,29860,29869,29954,30001,30282,30285,30289-30291,30337,30412,30417,30425,30430,30438,30443,30458,30466,30513-30514,30516-30521,30524,30526,30529-30530,31253-31254,31257-31259,31622,33124,33142,36083,36435,37651,38524,38757,39645,39659,39759,39795,39807-39808,39831,39850,39956,40148,40169,40183,40241,40255,40257,40259,40269,40271,40400,40446,40449,40457,40538,40604,40677,40692,40704,40723,40736,40833,41082,41303,41306,41393,41398
 ,41457,41470,41483,41496,41522,41662,42056,42119-42120,42258-42261,42424,42433,42892-42893,43511-43512,44021,44048,44842,44993,45936,45971,45997,46474-46478,46483,46485,46682,46895,46996,47341,47947-47951,48241,49380,49382-49388,49876
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><span class="cx" style="display: block; padding: 0 10px">Index: branches/3.7/src
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/3.7/src     2021-01-30 21:28:58 UTC (rev 50107)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/3.7/src      2021-01-30 21:29:39 UTC (rev 50108)
</ins><a id="branches37src"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/3.7/src</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/4.8/src:42478
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/4.9/src:42434,49653
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.0/src:43988,43994,44014,44017,44047
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk/src:18512,25880,25882-25884,25889,25891,25893,25895,25897,25899,25902,25915,25921,25923,25925,25929,25933,25954,25956,25974-25975,25977,25986,26087,26091,26095,26149,26252,26307,26318,26449,26512,26705,26871,26909-26910,26940,27086,27168,27385,27906,27928,28113,28129,28799,28873,28943,28961,28964,28966-28967,29120,29251,29503,29783,29860,29869,29954,30001,30282,30285,30289-30291,30513-30514,30516-30521,30524,30526,30529-30530,31253-31254,31257-31259,31622,33124,33142,36083,36435,37651,38524,39645,39659,39759,39795,39807-39808,39831,39850,39956,40148,40169,40183,40241,40255,40257,40259,40269,40271,40400,40446,40449,40457,40538,40604,40677,40692,40704,40723,40736,40833,41082,41303,41306,41393,41398,41457,41470,41483,41496,41522,41662,42056,42119-42120,42258-42261,42424,42892-42893,44021,44048,44842,44993,45936,45971,45997,46474-46478,46483,46485,46895,47341,47947-47951,48241,49380,4
 9382-49388,49876
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk/src:18512,25880,25882-25884,25889,25891,25893,25895,25897,25899,25902,25915,25921,25923,25925,25929,25933,25954,25956,25974-25975,25977,25986,26087,26091,26095,26149,26252,26307,26318,26449,26512,26705,26871,26909-26910,26940,27086,27168,27385,27906,27928,28113,28129,28799,28873,28943,28961,28964,28966-28967,29120,29251,29503,29783,29860,29869,29954,30001,30282,30285,30289-30291,30513-30514,30516-30521,30524,30526,30529-30530,31253-31254,31257-31259,31622,33124,33142,36083,36435,37651,38524,38757,39645,39659,39759,39795,39807-39808,39831,39850,39956,40148,40169,40183,40241,40255,40257,40259,40269,40271,40400,40446,40449,40457,40538,40604,40677,40692,40704,40723,40736,40833,41082,41303,41306,41393,41398,41457,41470,41483,41496,41522,41662,42056,42119-42120,42258-42261,42424,42892-42893,43511-43512,44021,44048,44842,44993,45936,45971,45997,46474-46478,46483,46485,46682,46895,46996,4
 7341,47947-47951,48241,49380,49382-49388,49876
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches37testsphpunitincludestestcasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/3.7/tests/phpunit/includes/testcase.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/3.7/tests/phpunit/includes/testcase.php  2021-01-30 21:28:58 UTC (rev 50107)
+++ branches/3.7/tests/phpunit/includes/testcase.php    2021-01-30 21:29:39 UTC (rev 50108)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,36 +52,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->start_transaction();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->expectDeprecated();
</span><span class="cx" style="display: block; padding: 0 10px">                add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        }
-
-       /**
-        * Unregister existing post types and register defaults.
-        *
-        * Run before each test in order to clean up the global scope, in case
-        * a test forgets to unregister a post type on its own, or fails before
-        * it has a chance to do so.
-        */
-       protected function reset_post_types() {
-               foreach ( get_post_types() as $pt ) {
-                       _unregister_post_type( $pt );
-               }
-               create_initial_post_types();
-       }
-
-       /**
-        * Unregister existing taxonomies and register defaults.
-        *
-        * Run before each test in order to clean up the global scope, in case
-        * a test forgets to unregister a taxonomy on its own, or fails before
-        * it has a chance to do so.
-        */
-       protected function reset_taxonomies() {
-               foreach ( get_taxonomies() as $tax ) {
-                       _unregister_taxonomy( $tax );
-               }
-               create_initial_taxonomies();
-       }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         function tearDown() {
</span><span class="cx" style="display: block; padding: 0 10px">                global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">                $this->expectedDeprecated();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -126,6 +98,57 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Allow tests to be skipped if the HTTP request times out.
+        *
+        * @param array|WP_Error $response HTTP response.
+        */
+       public function skipTestOnTimeout( $response ) {
+               if ( ! is_wp_error( $response ) ) {
+                       return;
+               }
+               if ( 'connect() timed out!' === $response->get_error_message() ) {
+                       $this->markTestSkipped( 'HTTP timeout' );
+               }
+
+               if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
+                       $this->markTestSkipped( 'HTTP timeout' );
+               }
+
+               if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
+                       $this->markTestSkipped( 'HTTP timeout' );
+               }
+
+       }
+
+       /**
+        * Unregister existing post types and register defaults.
+        *
+        * Run before each test in order to clean up the global scope, in case
+        * a test forgets to unregister a post type on its own, or fails before
+        * it has a chance to do so.
+        */
+       protected function reset_post_types() {
+               foreach ( get_post_types() as $pt ) {
+                       _unregister_post_type( $pt );
+               }
+               create_initial_post_types();
+       }
+
+       /**
+        * Unregister existing taxonomies and register defaults.
+        *
+        * Run before each test in order to clean up the global scope, in case
+        * a test forgets to unregister a taxonomy on its own, or fails before
+        * it has a chance to do so.
+        */
+       protected function reset_taxonomies() {
+               foreach ( get_taxonomies() as $tax ) {
+                       _unregister_taxonomy( $tax );
+               }
+               create_initial_taxonomies();
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Saves the action and filter-related globals so they can be restored later.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * Stores $merged_filters, $wp_actions, $wp_current_filter, and $wp_filter
</span></span></pre></div>
<a id="branches37testsphpunittestshttpbasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/3.7/tests/phpunit/tests/http/base.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/3.7/tests/phpunit/tests/http/base.php    2021-01-30 21:28:58 UTC (rev 50107)
+++ branches/3.7/tests/phpunit/tests/http/base.php      2021-01-30 21:29:39 UTC (rev 50108)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,6 +44,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirect_on_301() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 5 : 5 & 301
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 5) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals(200, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -51,6 +53,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirect_on_302() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 5 : 5 & 302
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 5) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals(200, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -61,6 +65,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirect_on_301_no_redirect() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 5 > 0 & 301
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?code=301&rt=' . 5, array('redirection' => 0) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals(301, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -71,6 +77,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirect_on_302_no_redirect() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 5 > 0 & 302
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals(302, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,6 +86,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirections_equal() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 5 - 5
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals(200, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -85,6 +95,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_no_head_redirections() {
</span><span class="cx" style="display: block; padding: 0 10px">                // No redirections on HEAD request:
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 1, array('method' => 'HEAD') );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 302, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -95,6 +107,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirect_on_head() {
</span><span class="cx" style="display: block; padding: 0 10px">                // Redirections on HEAD request when Requested
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?rt=' . 5, array('redirection' => 5, 'method' => 'HEAD') );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 200, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,6 +116,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirections_greater() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 10 > 5
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?rt=' . 10, array('redirection' => 5) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertTrue( is_wp_error($res), print_r($res, true) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,6 +124,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirections_greater_edgecase() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 6 > 5 (close edgecase)
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?rt=' . 6, array('redirection' => 5) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertTrue( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,6 +132,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirections_less_edgecase() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 4 < 5 (close edgecase)
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?rt=' . 4, array('redirection' => 5) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,6 +143,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_redirections_zero_redirections_specified() {
</span><span class="cx" style="display: block; padding: 0 10px">                // 0 redirections asked for, Should return the document?
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request($this->redirection_script . '?code=302&rt=' . 5, array('redirection' => 0) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 302, (int)$res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -135,6 +157,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        function test_location_header_on_201() {
</span><span class="cx" style="display: block; padding: 0 10px">                // Prints PASS on initial load, FAIL if the client follows the specified redirection
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request( $this->redirection_script . '?201-location=true' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'PASS', $res['body']);
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -149,6 +173,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Test 301 - POST to POST
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request( $url, array( 'method' => 'PUT', 'timeout' => 30 ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( !empty( $res['headers']['location'] ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,6 +187,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $headers = array('test1' => 'test', 'test2' => 0, 'test3' => '');
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request( $this->redirection_script . '?header-check', array('headers' => $headers) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error($res) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $headers = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -184,41 +211,63 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $size = 87348;
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_request( $url, array( 'stream' => true, 'timeout' => 30 ) ); //Auto generate the filename.
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Cleanup before we assert, as it'll return early. 
+               if ( ! is_wp_error( $res ) ) {
+                       $filesize = filesize( $res['filename'] );
+                       unlink( $res['filename'] );
+               }
+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertFalse( is_wp_error( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( '', $res['body'] ); // The body should be empty.
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same..)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $size, filesize($res['filename']) ); // Check that the file is written to disk correctly without any extra characters
-
-               unlink($res['filename']); // Remove the temporary file
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Test POST redirection methods
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @dataProvider data_post_redirect_to_method_300
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @ticket 17588
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_post_redirect_to_method_300() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_post_redirect_to_method_300( $response_code, $method ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Test 300 - POST to POST
-               $res = wp_remote_post( add_query_arg( 'response_code', 300, $url ), array( 'timeout' => 30 ) );
-               $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Test 301 - POST to POST
-               $res = wp_remote_post( add_query_arg( 'response_code', 301, $url ), array( 'timeout' => 30 ) );
-               $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->skipTestOnTimeout( $res );
+               $this->assertEquals( $method, wp_remote_retrieve_body( $res ) );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Test 302 - POST to GET
-               $res = wp_remote_post( add_query_arg( 'response_code', 302, $url ), array( 'timeout' => 30 ) );
-               $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) );
-
-               // Test 303 - POST to GET
-               $res = wp_remote_post( add_query_arg( 'response_code', 303, $url ), array( 'timeout' => 30 ) );
-               $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) );
-
-               // Test 304 - POST to POST
-               $res = wp_remote_post( add_query_arg( 'response_code', 304, $url ), array( 'timeout' => 30 ) );
-               $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_post_redirect_to_method_300() {
+               return array(
+                       // Test 300 - POST to POST
+                       array(
+                               300,
+                               'POST',
+                       ),
+                       // Test 301 - POST to POST
+                       array(
+                               301,
+                               'POST',
+                       ),
+                       // Test 302 - POST to GET
+                       array(
+                               302,
+                               'GET',
+                       ),
+                       // Test 303 - POST to GET
+                       array(
+                               303,
+                               'GET',
+                       ),
+                       // Test 304 - POST to POST
+                       array(
+                               304,
+                               'POST',
+                       ),
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -238,6 +287,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_get( $url, $args );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -251,10 +302,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1';
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_head( $url, array( 'timeout' => 30 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertInternalType( 'array', wp_remote_retrieve_header( $res, 'location' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertCount( 2, wp_remote_retrieve_header( $res, 'location' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_get( $url, array( 'timeout' => 30 ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -268,6 +322,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?cookie-test=1';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_get( $url );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -282,8 +338,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $this->markTestSkipped( 'This install of PHP does not support SSL' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $res = wp_remote_get( 'https://wordpress.org/' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( ! is_wp_error( $res ), print_r( $res, true ) );
-       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->skipTestOnTimeout( $res );
+               $this->assertTrue( ! is_wp_error( $res ), print_r( $res, true ) );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="branches37testsphpunittestshttpfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/3.7/tests/phpunit/tests/http/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/3.7/tests/phpunit/tests/http/functions.php       2021-01-30 21:28:58 UTC (rev 50107)
+++ branches/3.7/tests/phpunit/tests/http/functions.php 2021-01-30 21:29:39 UTC (rev 50108)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,11 +14,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function test_head_request() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // this url give a direct 200 response
-               $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
-               $response = wp_remote_head( $url );
-               $headers = wp_remote_retrieve_headers( $response );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // this url give a direct 200 response
+               $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
+               $response = wp_remote_head( $url );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->skipTestOnTimeout( $response );
+
+               $headers = wp_remote_retrieve_headers( $response );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertInternalType( 'array', $headers, "Reply wasn't array." );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'image/jpeg', $headers['content-type'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( '40148', $headers['content-length'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,61 +29,64 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function test_head_redirect() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // this url will 301 redirect
-               $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
-               $response = wp_remote_head( $url );
-               $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // this url will 301 redirect
+               $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
+               $response = wp_remote_head( $url );
+
+               $this->skipTestOnTimeout( $response );
+               $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       function test_head_404() {
-               $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
-               $headers = wp_remote_head( $url );
-
-               $this->assertInternalType( 'array', $headers, "Reply wasn't array." );
-               $this->assertEquals( '404', wp_remote_retrieve_response_code( $headers ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       function test_head_404() {
+               $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
+               $response = wp_remote_head( $url );
+
+               $this->skipTestOnTimeout( $response );
+               $this->assertInternalType( 'array', $response, "Reply wasn't array." );
+               $this->assertEquals( '404', wp_remote_retrieve_response_code( $response ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       function test_get_request() {
-               $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
-               $file = tempnam('/tmp', 'testfile');
-
-               $headers = wp_get_http($url, $file);
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        function test_get_request() {
+               $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';
+
+               $response = wp_remote_get( $url );
+
+               $this->skipTestOnTimeout( $response );
+
+               $headers = wp_remote_retrieve_headers( $response );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 // should return the same headers as a head request
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertInternalType( 'array', $headers, "Reply wasn't array." );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'image/jpeg', $headers['content-type'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( '40148', $headers['content-length'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( '200', $headers['response'] );
-
-               // make sure the file is ok
-               $this->assertEquals( 40148, filesize($file) );
-               $this->assertEquals( 'b0371a0fc575fcf77f62cd298571f53b', md5_file($file) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_get_redirect() {
-               // this will redirect to asdftestblog1.files.wordpress.com
-               $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
-               $file = tempnam('/tmp', 'testfile');
-
-               $headers = wp_get_http($url, $file);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_get_redirect() {
+               // this will redirect to asdftestblog1.files.wordpress.com
+               $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $response = wp_remote_get( $url );
+
+               $this->skipTestOnTimeout( $response );
+
+               $headers = wp_remote_retrieve_headers( $response );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 // should return the same headers as a head request
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertInternalType( 'array', $headers, "Reply wasn't array." );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'image/jpeg', $headers['content-type'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( '40148', $headers['content-length'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( '200', $headers['response'] );
-
-               // make sure the file is ok
-               $this->assertEquals( 40148, filesize($file) );
-               $this->assertEquals( 'b0371a0fc575fcf77f62cd298571f53b', md5_file($file) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_get_redirect_limit_exceeded() {
-               // this will redirect to asdftestblog1.files.wordpress.com
-               $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
-               $file = tempnam('/tmp', 'testfile');
-               // pretend we've already redirected 5 times
-               $headers = wp_get_http( $url, $file, 6 );
-               $this->assertFalse( $headers );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_get_redirect_limit_exceeded() {
+               // this will redirect to asdftestblog1.files.wordpress.com
+               $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';
+
+               // pretend we've already redirected 5 times
+               $response = wp_remote_get( $url, array( 'redirection' => -1 ) );
+
+               $this->skipTestOnTimeout( $response );
+               $this->assertTrue( is_wp_error( $response ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>