I am doing an HTTP post to a url to retrieve the contents of a file using php and curl as follows:
$url = SITE_URL . 'filename.html';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3');
$content = curl_exec($curl);
$cerr = curl_error($curl);
$info = curl_getinfo($curl);
curl_close($curl);
This was working fine on one server, but when I moved to a new server it was blocked by ModSec rule 390616 - "Post request must have a content length header". As a quick fix I have had that rule white-listed, but I would prefer not to have to do that. So how do I add a content length header to the above code please?