Ok PHP Genii.. I need your help with this one.. stumped for days..

I have two different servers, configured 99% the same. On one server, curl POSTS with sessions, jumping to different pages , logging everything beautifully. The other server doesn't work and here is what I see..

(Its a bot which views and captures segments of webpages behind session controlled authenticiation)

On the working server (server1) CURL report shows:

  • Connected to xxx.com (x.x.x.x) port 80
    > POST /login.php HTTP/1.1
    Content-Type: application/x-www-form-urlencoded

On the broken server (server2)

  • Connected to xxx.com (x.x.x.x) port 80
    > GET /login.php HTTP/1.1
    Content-Type: text/html; etc etc

Both servers running the EXACT same CURL instructions, but the latter insists on switching to GET instead of POST, even when post is called for and get is turned off...

Is something controlling access to the cookie? I granted all permissions and the cookie does write to the specified location... Is it a curl configuration or lib dependency issue?

What you may need to know:
Server 1: fedora core, cpanel, curl 15.x.x
Server 2: centos, cpanel, curl 19.x.x

Let me add that curl works find with basic authentication user:pw on both servers

What you think and thanks in advance for your feedback... I am not bothering to post the curl commands because I know they work on one of the servers... But let me know if you think you need to see them..

    Have you looked for discrepancies in php.ini?

      I have and spotted nothing.. Anything specific come to mind which you think i should look at?

      Ok.. here is one curveball.. Prior to installing cpanel on the WORKING server, I installed an open, unsecured version of xampp, and then wrote over that installation with cpanel..

      The broken server was a clean install of OS, Cpanel

      But I even tried to replicate the installation process with xampp and no luck...

        Sorry I didn't get back with you earlier. But I've been busy revamping my business app.

        I don't think a previous installation of xampp is the problem. GET is the default method used by cURL, it is possible that your POST instruction is failing for external reasons and therefore it is falling back on GET. Also if you use the -L flag it will rollback to GET after an attempt by POST. Now why is your POST transaction failing is the mystery to be uncovered. Please post back if you are able to make any progress. You've sparked my curiosity.

          Thanks YAOMK. I actually solved this one on my own the day of the original post.. and you hit the nail on the head.

          For some reason, my post instruction was failing and defaulting to GET. Of course I didn't determine this until after countless CURL, dependency library and apache installations.

          For the benefit of others who are studying curl, my code contained both CURLOPT_POST, TRUE and CURLOPT_HTTPGET FALSE which worked fine on one installation but not the other (The one with the configured IDN lib worked fine both ways..

          On the server which defaulted to get, I just yanked out the GET FALSE line and BAM it POSTED perfectly. The GET was overriding the POST.

          One last question and I'll mark this resolved..

          If I reconfigure and recompile a previously running curl install to change some settings.. do I need to compile apache or will restarting apache load the new curl configuration?

            Haha tell me about countless reinstalls. I think we have all been there, I know I have. I'm glad you were able to figure this out.

            You do not need to recompile Apache. If you are on a linux server, take advantage of either apt or yum and install the binaries via repository as in:

            In a linux terminal:

            sudo apt-get install php5-curl
            
            //or 
            
            sudo yum install php5-curl
            
            service httpd restart

            Good luck.

              Write a Reply...