PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTTP » HTTP_Client » Bug #9428

problem with https calls

Details

Submitted2006-11-23 12:20 UTC
Fromjestershoot at inbox dot ru
StatusBogus
PackageHTTP_Client
PHP Version5.1.6
OSWin XP
Roadmaps(Not assigned)

Comments

[2006-11-23 12:20 UTC] jestershoot at inbox dot ru

Description:
------------
I have a problem with https call. when i try to call

https://www.e-gold.com/acct/login.html

for example, browser hangs. What am I doing wrong?

If HTTP_Client works with https at all?

Test script:
---------------
<?php

require_once 'HTTP/Client.php';

$req =& new HTTP_Client();

if (!PEAR::isError($req->get('https://www.e-gold.com/acct/login.html'))) {

$a = $req->currentResponse();
$f = $a['body'];
}
echo $f;
?>

Expected result:
----------------
loaded page

Actual result:
--------------
browser hangs

[2007-01-07 16:36 UTC] bugs dot pear dot php dot net at daskalou dot com

I'm having this same problem.

I tried doing it in CLI mode and I get this:

Segmentation fault (core dumped)

I managed to track down the problem to the Net_Socket PEAR class.

Net_Socket opens a socket connection to send the HTTPS request using the PHP function fsockopen() in its connect() method. The Segmentation fault occurs when Net_Socket attempts to close the socket using the PHP function fclose().

I have experienced the same problem when I tried using the curl_* functions instead of this HTTP_Client class to try to retrieve a response. Upon the call to the PHP function curl_close() I get the same Segmentation fault.

Note that the problem only occurs when using the HTTPS protocol but not with the HTTP protocol.

Others are having this same problem with HTTPS/SSL access but it looks like the PHP developers are saying it's not a bug with PHP but rather with MySQL:

http://bugs.php.net/bug.php?id=39570
http://bugs.php.net/bug.php?id=38393

My current installation details are:

PHP 5.2
MySQL 5.0.27-0
Apache 1.3.37
Hosted on a CentOS 3.8 installation (which includes cPanel)

This bug was not present when I had PHP 4.4.3 and MySQL 5.0.25 installed.

I'll try and post this as part of the PHP bugs when I get a chance...

[2007-01-07 16:45 UTC] bugs dot pear dot php dot net at daskalou dot com

Submitted this as a new PHP bug here:

http://bugs.php.net/bug.php?id=40049

[2007-01-07 19:12 UTC] bugs dot pear dot php dot net at daskalou dot com

Ok, so I've been investigating this bug all damn night, and have concluded that it is most likely a MySQL bug (see http://bugs.mysql.com/bug.php?id=19810).

As a temporary solution, if you want to access sites using the HTTPS protocol you can use the "curl" system command by using the backticks operator in PHP, for example:

<?php

$url = "https://www.e-gold.com/acct/login.html";
$username = "blah";
$password = "bleh";

// Using the POST method
$command = "curl \"$url\" --data-binary \"".
"user=".urlencode($username).
"&".
"password=".urlencode($password).
"\"";

$f = `$command`;

// Using the GET method
$command = "curl \"$url?".
"user=".urlencode($username).
"&".
"password=".urlencode($password).
"\"";

$f = `$command`;
?>

Oh yeah, I'm assuming you're using Linux ;)

There's an abundance of other useful parameters you can pass into the curl system command, just do a "man curl" at the command prompt to see what's on offer (the --max-redirs option, for example, sets the maximum number of redirections curl is allowed to follow).

Also the "wget" command will work with this too using something like "wget -O - \"$url\" 2>/dev/null" or even the "lynx" command (eg. "lynx --source \"$url\"). View the man pages on those commands to see how to pass GET or POST data to the URLs.

Hope that helps.