Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix curling #3

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
19 changes: 0 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,8 @@ cache:
- node_modules
matrix:
include:
- php: 5.5
env: WP_TRAVISCI=travis:js
- 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
Expand Down
14 changes: 1 addition & 13 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,9 @@ 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']
args: ['-c', 'phpunit.xml.dist', '--group', 'external-http', '--filter', 'test_get_request']
}
},
uglify: {
Expand Down
7 changes: 7 additions & 0 deletions src/wp-includes/Requests/Transport/cURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -309,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)) {
Expand Down Expand Up @@ -446,6 +452,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_bytes));

// Are we limiting the response size?
if ($this->response_byte_limit) {
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/http/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down