title: CURL cannot run URL and return 302
body: <p>I'm trying to run an URL (which have signout functionality) through the CURL. But it is returning 302 http code. Same url when i run through the POSTMAN ( Google Chrome addon ) or POSTER ( Firefox Addon) , then it is return proper result ( {"status" : "success" } ). Any help would be greatly appreciated.</p>
  
  <p>URL (JAVA APPLICATION URL)  : <a href="http://website.mywebsite.com:8083/VideoBook/signout.action" rel="noreferrer">http://website.mywebsite.com:8083/VideoBook/signout.action</a></p>
  
  <p>MY CODE : </p>
  
  <pre><code> // Open log file
          $logfh = fopen("GeoserverPHP.log", 'w') or die("can't open log file");
  
          // Initiate cURL session
          $service = "http://website.mywebsite.com:8083/VideoBook/";
  
  
  $request = "signout.action";
  
               $url = $service . $request;
          $ch = curl_init($url);
  
          // Optional settings for debugging
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_VERBOSE, true);
  
  
   curl_setopt($ch, CURLOPT_STDERR, $logfh);
  
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  
  curl_setopt($ch, CURLOPT_COOKIESESSION, true);
  
  curl_setopt($ch, CURLOPT_REFERER, true); 
  curl_setopt($ch, CURLOPT_COOKIEJAR, true); 
  curl_setopt($ch, CURLOPT_COOKIEFILE, true); 
      //Required GET request settings
  
  
    //  $passwordStr = "geosolutions:Geos";
         // curl_setopt($ch, CURLOPT_USERPWD, $passwordStr);
  
           //GET data
          curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
  
          //GET return code
          $successCode = 200;
  
          $buffer = curl_exec($ch);
  
          echo "CURL INFO : &lt;BR/&gt; " ; 
  
          print_r(curl_getinfo($ch));
  
          echo "CURL OUTPUT  : &lt;BR/&gt; " ; 
  
          print_r($buffer);  
          // Check for errors and process results
          $info = curl_getinfo($ch);
          if ($info['http_code'] != $successCode) {
            $msgStr = "# Unsuccessful cURL request to ";
            $msgStr .= $url." [". $info['http_code']. "]\n";
            fwrite($logfh, $msgStr);
          } else {
            $msgStr = "# Successful cURL request to ".$url."\n";
            fwrite($logfh, $msgStr);
          }
          fwrite($logfh, $buffer."\n");
  
          curl_close($ch);
          fclose($logfh);
  </code></pre>
  
  <p>OUTPUT IN BROWSER : </p>
  
  <pre><code>   CURL INFO : 
   Array
  (
      [url] =&gt; http://website.mywebsite.com:8083/VideoBook/signout.action
      [content_type] =&gt; 
      [http_code] =&gt; 302
      [header_size] =&gt; 254
      [request_size] =&gt; 105
      [filetime] =&gt; -1
      [ssl_verify_result] =&gt; 0
      [redirect_count] =&gt; 0
      [total_time] =&gt; 0.58976
      [namelookup_time] =&gt; 0.004162
      [connect_time] =&gt; 0.297276
      [pretransfer_time] =&gt; 0.297328
      [size_upload] =&gt; 0
      [size_download] =&gt; 0
      [speed_download] =&gt; 0
      [speed_upload] =&gt; 0
      [download_content_length] =&gt; 0
      [upload_content_length] =&gt; 0
      [starttransfer_time] =&gt; 0.589739
      [redirect_time] =&gt; 0
      [redirect_url] =&gt; https://hpecp.mywebsite.com:8443/cas/login?service=http%3A%2F%2Fwebsite.mywebsite.com%3A8083%2FVideoBook%2Flogin.action
      [primary_ip] =&gt; 125.21.227.2
      [certinfo] =&gt; Array
          (
          )
  
      [primary_port] =&gt; 8083
      [local_ip] =&gt; 10.0.0.8
      [local_port] =&gt; 50710
  )
  CURL OUTPUT  : 
  </code></pre>
  
  <p>LOG File Details : </p>
  
  <pre><code>* Hostname was NOT found in DNS cache
  *   Trying 125.21.227.2...
  * Connected to website.mywebsite.com (125.21.227.2) port 8083 (#0)
  &gt; GET /VideoBook/signout.action HTTP/1.1
  Host: website.mywebsite.com:8083
  Accept: application/json
  
  &lt; HTTP/1.1 302 Moved Temporarily
  * Server Apache-Coyote/1.1 is not blacklisted
  &lt; Server: Apache-Coyote/1.1
  &lt; Location: https://hpecp.mywebsite.com:8443/cas/login?service=http%3A%2F%2Fwebsite.mywebsite.com%3A8083%2FVideoBook%2Flogin.action
  &lt; Content-Length: 0
  &lt; Date: Tue, 20 May 2014 06:02:29 GMT
  &lt; 
  * Connection #0 to host website.mywebsite.com left intact
  * Issue another request to this URL: 'https://hpecp.mywebsite.com:8443/cas/login?service=http%3A%2F%2Fwebsite.mywebsite.com%3A8083%2FVideoBook%2Flogin.action'
  * Hostname was NOT found in DNS cache
  *   Trying 15.126.214.121...
  * Connected to hpecp.mywebsite.com (15.126.214.121) port 8443 (#1)
  * successfully set certificate verify locations:
  *   CAfile: none
    CApath: /etc/ssl/certs
  * Unknown SSL protocol error in connection to hpecp.mywebsite.com:8443 
  * Closing connection 1
  # Unsuccessful cURL request to http://website.mywebsite.com:8083/VideoBook/signout.action [302]
  </code></pre>