It looks like curl_setopt_array is different from just multiple invocations of curl_setopt. Consider this script:
$ch = curl_init('http://www.stackoverflow.com/'); [options] curl_exec($ch); var_dump(curl_getinfo($ch)); Now it sends a proper request if [options] are one of these:
curl_setopt_array($ch, array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => array('a' => 'b'), )); or
curl_setopt_array($ch, array( CURLOPT_POSTFIELDS => array('a' => 'b'), )); or
curl_setopt($ch, CURLOPT_POSTFIELDS, 'a=b'); curl_setopt($ch, CURLOPT_POST, 1); BUT NOT this way:
curl_setopt_array($ch, array( CURLOPT_POSTFIELDS => array('a' => 'b'), CURLOPT_POST => true, )); It seems that the content-length is reset if CURLOPT_POST is set after CURLOPT_POSTFIELDS. Except it works ok if set with curl_setopt instead of curl_setopt_array.
Why is this?