From 4ddc28bc9861b3d2f8ec302f6d998e4c1213f2d5 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 16:57:36 +1000 Subject: [PATCH 01/12] Disable other tests --- Gruntfile.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6b2b6f3dba..9de2c95375 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -422,18 +422,6 @@ module.exports = function(grunt) { ] }, phpunit: { - 'default': { - cmd: 'phpunit', - args: ['-c', 'phpunit.xml.dist'] - }, - ajax: { - cmd: 'phpunit', - args: ['-c', 'phpunit.xml.dist', '--group', 'ajax'] - }, - multisite: { - cmd: 'phpunit', - args: ['-c', 'tests/phpunit/multisite.xml'] - }, 'external-http': { cmd: 'phpunit', args: ['-c', 'phpunit.xml.dist', '--group', 'external-http'] From caf9883e1375ac27e72654b8b96ac1fcf7c8c394 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 16:58:20 +1000 Subject: [PATCH 02/12] Check what the response is --- tests/phpunit/tests/http/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index 05bfc26266..3923fbbd06 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -42,6 +42,7 @@ function test_get_request() { $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; $response = wp_remote_get( $url ); + var_dump( $response ); $headers = wp_remote_retrieve_headers( $response ); // should return the same headers as a head request From c4c72903adfb412362d5698c0603d816b9474d13 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 17:08:26 +1000 Subject: [PATCH 03/12] Disable JS tests --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 449da33b1b..e9eeb69ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,6 @@ cache: - node_modules matrix: include: - - php: 5.5 - env: WP_TRAVISCI=travis:js - php: 5.2 env: WP_TRAVISCI=travis:phpunit - php: 5.3 From 9ef19028d1ef2225d13ca0ef4339819f3a057b44 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 17:16:21 +1000 Subject: [PATCH 04/12] Strip down to single test --- .travis.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index e9eeb69ffa..b5729ac275 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,25 +5,8 @@ cache: - node_modules matrix: include: - - php: 5.2 - env: WP_TRAVISCI=travis:phpunit - - php: 5.3 - env: WP_TRAVISCI=travis:phpunit - php: 5.4 env: WP_TRAVISCI=travis:phpunit - - php: 5.5 - env: WP_TRAVISCI=travis:phpunit - - php: 5.6 - env: WP_TRAVISCI=travis:phpunit - - php: 5.6 - env: WP_TRAVISCI=travis:phpunit WP_TRAVIS_OBJECT_CACHE=true - services: memcached - - php: hhvm - env: WP_TRAVISCI=travis:phpunit - - php: 7.0 - env: WP_TRAVISCI=travis:phpunit - - php: nightly - env: WP_TRAVISCI=travis:phpunit allow_failures: - php: hhvm - php: nightly From d800ab795cbf527b7cd79581743fa90da5d0ddc2 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 17:20:02 +1000 Subject: [PATCH 05/12] Turn verbose mode on --- src/wp-includes/Requests/Transport/cURL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/Requests/Transport/cURL.php b/src/wp-includes/Requests/Transport/cURL.php index 5f5c5dfb0a..9e47d77dbf 100755 --- a/src/wp-includes/Requests/Transport/cURL.php +++ b/src/wp-includes/Requests/Transport/cURL.php @@ -94,6 +94,7 @@ public function __construct() { $this->version = $curl['version_number']; $this->handle = curl_init(); + curl_setopt($this->handle, CURLOPT_VERBOSE, true); curl_setopt($this->handle, CURLOPT_HEADER, false); curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1); if ($this->version >= self::CURL_7_10_5) { From 92e1533cae2ba2ecaa2deaffeb33a5f99bd27b6c Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 17:30:54 +1000 Subject: [PATCH 06/12] Only run single request we're looking at --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9de2c95375..ce12488cf1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -424,7 +424,7 @@ module.exports = function(grunt) { phpunit: { 'external-http': { cmd: 'phpunit', - args: ['-c', 'phpunit.xml.dist', '--group', 'external-http'] + args: ['-c', 'phpunit.xml.dist', '--group', 'external-http', '--filter', 'test_get_request'] } }, uglify: { From 363da9346d4e416e5ad71b93562a71066e8a074f Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 18:12:55 +1000 Subject: [PATCH 07/12] Don't set buffer size --- src/wp-includes/Requests/Transport/cURL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/Requests/Transport/cURL.php b/src/wp-includes/Requests/Transport/cURL.php index 9e47d77dbf..30fbe3957a 100755 --- a/src/wp-includes/Requests/Transport/cURL.php +++ b/src/wp-includes/Requests/Transport/cURL.php @@ -373,7 +373,7 @@ protected function setup_handle($url, $headers, $data, $options) { if (true === $options['blocking']) { curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array(&$this, 'stream_headers')); curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array(&$this, 'stream_body')); - curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); + // curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); } } From 6160e6a82a11ee02d6a57cb93af390ca8bb22081 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 18:18:49 +1000 Subject: [PATCH 08/12] Check when we get the bytes passed in --- src/wp-includes/Requests/Transport/cURL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/Requests/Transport/cURL.php b/src/wp-includes/Requests/Transport/cURL.php index 30fbe3957a..19673de092 100755 --- a/src/wp-includes/Requests/Transport/cURL.php +++ b/src/wp-includes/Requests/Transport/cURL.php @@ -447,6 +447,7 @@ public function stream_headers($handle, $headers) { protected function stream_body($handle, $data) { $this->hooks->dispatch('request.progress', array($data, $this->response_bytes, $this->response_byte_limit)); $data_length = strlen($data); + var_dump(array($data_length, $this->response_byte_limit)); // Are we limiting the response size? if ($this->response_byte_limit) { From d482f80a0bc8b42d20f196fd4265e56751550f4e Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 18:19:11 +1000 Subject: [PATCH 09/12] Readd buffer size --- src/wp-includes/Requests/Transport/cURL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/Requests/Transport/cURL.php b/src/wp-includes/Requests/Transport/cURL.php index 19673de092..c9684cacfb 100755 --- a/src/wp-includes/Requests/Transport/cURL.php +++ b/src/wp-includes/Requests/Transport/cURL.php @@ -373,7 +373,7 @@ protected function setup_handle($url, $headers, $data, $options) { if (true === $options['blocking']) { curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array(&$this, 'stream_headers')); curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array(&$this, 'stream_body')); - // curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); + curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); } } From e5acb3cfb5286b586b546bb036297abac79b4ba7 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 18:23:09 +1000 Subject: [PATCH 10/12] Check total response size --- src/wp-includes/Requests/Transport/cURL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/Requests/Transport/cURL.php b/src/wp-includes/Requests/Transport/cURL.php index c9684cacfb..aba18d0626 100755 --- a/src/wp-includes/Requests/Transport/cURL.php +++ b/src/wp-includes/Requests/Transport/cURL.php @@ -447,7 +447,7 @@ public function stream_headers($handle, $headers) { protected function stream_body($handle, $data) { $this->hooks->dispatch('request.progress', array($data, $this->response_bytes, $this->response_byte_limit)); $data_length = strlen($data); - var_dump(array($data_length, $this->response_byte_limit)); + var_dump(array($data_length, $this->response_bytes)); // Are we limiting the response size? if ($this->response_byte_limit) { From 3a5a223971e7b7aa6578dc9fa0518ce4862d01cd Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 19:11:04 +1000 Subject: [PATCH 11/12] Try closing connection --- src/wp-includes/Requests/Transport/cURL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/Requests/Transport/cURL.php b/src/wp-includes/Requests/Transport/cURL.php index aba18d0626..486ecabe77 100755 --- a/src/wp-includes/Requests/Transport/cURL.php +++ b/src/wp-includes/Requests/Transport/cURL.php @@ -361,6 +361,7 @@ protected function setup_handle($url, $headers, $data, $options) { curl_setopt($this->handle, CURLOPT_URL, $url); curl_setopt($this->handle, CURLOPT_REFERER, $url); curl_setopt($this->handle, CURLOPT_USERAGENT, $options['useragent']); + $headers[] = 'Connection: close'; curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); if ($options['protocol_version'] === 1.1) { From d3951e4a0183d5a9a537fb198cc9616966f9623d Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Fri, 13 May 2016 19:28:48 +1000 Subject: [PATCH 12/12] Force closing the connection, if no header is set --- src/wp-includes/Requests/Transport/cURL.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/Requests/Transport/cURL.php b/src/wp-includes/Requests/Transport/cURL.php index 486ecabe77..ce3cf9c61f 100755 --- a/src/wp-includes/Requests/Transport/cURL.php +++ b/src/wp-includes/Requests/Transport/cURL.php @@ -310,6 +310,11 @@ public function &get_subrequest_handle($url, $headers, $data, $options) { protected function setup_handle($url, $headers, $data, $options) { $options['hooks']->dispatch('curl.before_request', array(&$this->handle)); + // Force closing the connection for old versions of cURL (<7.22). + if ( ! isset( $headers['Connection'] ) ) { + $headers['Connection'] = 'close'; + } + $headers = Requests::flatten($headers); if (!empty($data)) { @@ -361,7 +366,6 @@ protected function setup_handle($url, $headers, $data, $options) { curl_setopt($this->handle, CURLOPT_URL, $url); curl_setopt($this->handle, CURLOPT_REFERER, $url); curl_setopt($this->handle, CURLOPT_USERAGENT, $options['useragent']); - $headers[] = 'Connection: close'; curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); if ($options['protocol_version'] === 1.1) {