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 support for HHVM #106

Merged
merged 3 commits into from
Mar 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions library/Requests/Transport/cURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function request($url, $headers = array(), $data = array(), $options = ar
}

$this->process_response($response, $options);
curl_close($this->fp);
return $this->headers;
}

Expand Down Expand Up @@ -274,7 +275,6 @@ protected function setup_handle($url, $headers, $data, $options) {

public function process_response($response, $options) {
if ($options['blocking'] === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the removal here? My group is using non-blocking mode, and the flow here doesn't really look like there should ever have been a double-close. However, this looks like it will keep curl open a bit longer than necessary.

curl_close($this->fp);
$fake_headers = '';
$options['hooks']->dispatch('curl.after_request', array(&$fake_headers));
return false;
Expand All @@ -293,7 +293,6 @@ public function process_response($response, $options) {
}
$this->info = curl_getinfo($this->fp);

curl_close($this->fp);
$options['hooks']->dispatch('curl.after_request', array(&$this->headers));
return $this->headers;
}
Expand Down
4 changes: 4 additions & 0 deletions library/Requests/Transport/fsockopen.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ public static function test($capabilities = array()) {
if (isset( $capabilities['ssl'] ) && $capabilities['ssl']) {
if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse'))
return false;

// Currently broken, thanks to https://github.com/facebook/hhvm/issues/2156
if (strpos(PHP_VERSION, 'hiphop') !== false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The supported way to check for hhvm is if(defined('HHVM_VERSION'))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, thanks. I'll switch to that then.

return false;
}

return true;
Expand Down
10 changes: 9 additions & 1 deletion tests/Transport/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

abstract class RequestsTest_Transport_Base extends PHPUnit_Framework_TestCase {
public function setUp() {
if (!call_user_func(array($this->transport, 'test'))) {
$callback = array($this->transport, 'test');
$supported = call_user_func($callback);

if (!$supported) {
$this->markTestSkipped($this->transport . ' is not available');
return;
}

$ssl_supported = call_user_func($callback, array('ssl' => true));
if (!$ssl_supported) {
$this->skip_https = true;
}
}
protected $skip_https = false;

Expand Down
8 changes: 0 additions & 8 deletions tests/Transport/fsockopen.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,4 @@

class RequestsTest_Transport_fsockopen extends RequestsTest_Transport_Base {
protected $transport = 'Requests_Transport_fsockopen';

protected $skip_https = false;
public function setUp() {
// If OpenSSL isn't loaded, this should fail
if (!defined('OPENSSL_VERSION_NUMBER')) {
$this->skip_https = true;
}
}
}