cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

curl not working from browser

From: Scott Poarch <scott_at_globalhost.com>
Date: Thu, 3 Jun 2004 23:53:25 -1000

We've got a couple of RH9 boxes running with:

kernel: 2.4.20-8
PHP 4.3.5 (cgi)
httpd-2.0.40-21
curl-7.9.8-5

from both of these we can run a very simple test script from the
command line:

php u.php

and it returns output correctly.

BUT, from one of the boxes that same script will work in a browser, but
in the other it just hangs. If we put a timeout on the script it will
just stop and there's nothing in the source code.

We can't find any errors anywhere to tell us why it would fail from the
browser and not on a command line.

We pointed the URL to a local domain and tailed the access log. We get
the same result in the domain we're accessing through curl from a
command line or the browser, whether or not the browser action is
successful.

Anyone ever had this problem before? Any ideas?

Here's the script we're running (of course "domain.com" is an actual
domain in the script):

<html>
<body>
<?php
         $sXML = "Some obviously invalid XML";
         if (!$ch = curl_init()) {
                 $success = false;
                 $errormsg = "cURL package not installed in PHP";
         }else{
                 curl_setopt($ch,
CURLOPT_URL,'https://www.domain.com/index.html');
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $sXML);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 10);
                 curl_setopt($ch, CURLOPT_VERBOSE, 1);
                 curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
                 $res = curl_exec($ch);
                 if(curl_error($ch) != ""){
                         $vsRESPMSG= "Error with cURL installation: " .
curl_error($ch) . "<br>";
                         flush();
                 }
                 curl_close($ch);
                 print str_replace("<","<br>&lt;",$res) . "<BR>\n";
         }
?>
</body>
</html>
Received on 2004-06-04