title: PHP cURL timeout in redirections
body: <p>I was testing the 303 redirection in PHP for a use case in one of my company websites and I noticed a huge delay between 2 different cases, one execution was normal and the other lasted 10 seconds, I realized that was the timeout I set (with the CURLOPT_TIMEOUT flag).</p>
  
  <p>The test was to try the case where a POST query transforms into a GET query after a redirection.</p>
  
  <p>I tested it with 301 and 302 redirections also and the result was the same. Finally after struggling a lot with this issue I found the solution and I thought it'd be interesting to share.</p>
  
  <p>Redirect page</p>
  
  <pre><code>&lt;?php
  
  header("HTTP/1.1 303 See Other");    
  header("Location: http://127.0.0.1/test-303-redirection-2.html");
  </code></pre>
  
  <p>cURL example script</p>
  
  <pre><code>&lt;?php
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1/test-303-redirection-1.php");
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, "field1=value1&amp;field2=value2");
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'host: 127.0.0.1',
      'accept: */*',
      'content-length: 29',
      'content-type: application/x-www-form-urlencoded'
      )
  );
  
  $theResponse  = curl_exec($ch);
  
  print_r(curl_getinfo($ch)) ;
  </code></pre>
  
  <p>This script lasted 10 seconds every time it was executed.</p>