Curl Lite in PHP doesn't work.

498 views
Skip to first unread message

Paulo Lindoso

unread,
Mar 13, 2015, 8:16:47 AM3/13/15
to google-a...@googlegroups.com
Hello All,

Minor rant mixed with a question.  Please bear with me.

I have a PHP app which I really wanted to run on GAE.  However, this app makes extensive use of cURL, which was unsupported by Google.   When Google announced that AppEngine 1.9.18 would support cURL, I was very happy.

Upgraded, rewrote app.yaml, php.ini, yadda, yadda, yadda and run... No use and the most peculiar behaviour.

// begin CURL routine

        $chv = curl_init();
        $header[0] = "Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1";
        $header[] = "Accept: */*";
        //$user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:28.0) Gecko/20100101 Firefox/28.0";
       
        curl_setopt($chv, CURLOPT_URL, $url);
        //curl_setopt($chv, CURLOPT_USERAGENT, $user_agent);
        curl_setopt($chv, CURLOPT_HTTPHEADER, $header);
        curl_setopt($chv, CURLOPT_REFERER, '');
        //curl_setopt($chv, CURLOPT_ENCODING, 'gzip, deflate');
        curl_setopt($chv, CURLOPT_AUTOREFERER, true);
        curl_setopt($chv, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($chv, CURLOPT_TIMEOUT, 10);
        curl_setopt($chv, CURLOPT_HEADER, false);
        curl_setopt($chv, CURLOPT_POST, true);
        curl_setopt($chv, CURLOPT_POSTFIELDS, $postFields);
       
        $html = curl_exec($chv); // execute the curl command

        CakeLog::write('debug',"CURL:".$html);
        /* If there is some error in CURL, relay it to View
           Essentially, we will abort "nicely" and log the CURL error in JS Console to help debugging */
        $curl_errno = curl_errno($chv);
        $curl_error = curl_error($chv);

This is a fairly standard cURL POST routine.  All variables are correctly and properly set.  Now what happens is pretty bizarre;  cURL RETRIEVES the page content ($html returns the correct page!), but $curl_errno/$curl_error are set to "3" and "No URL set"...  Needless to say, this completely breaks error handling...

Investigation showed that Google's cURL support is actually a code layer for URL Fetch, so my guess is that this is what's causing the problem.

Can anybody provide some light?

(now the rant...)  Since I am running out of time to release the app, I don't really have the time (and patience) to debug Google's CurlLite, so I guess Amazon will win... That said I am somewhat disappointed that Google chose to insist in using URL fetch instead of using native cURL, which has been used for years by the community and it's been proven simple, quick and secure so far. Ah well... so much for ranting... back to work... :)

Thanks in advance!

Stuart Langley

unread,
Mar 15, 2015, 1:59:45 AM3/15/15
to google-a...@googlegroups.com
You can use the full curl extension if you wish. 

We don't claim curl_lite to be a full implementation of cURL, which you have available by simply adding the extension in your php.ini file. It's designed for scenarios that can be satisfied using URLFetch as that is likely to be more efficient then cURL over a socket connection. 
Reply all
Reply to author
Forward
0 new messages