So, long story short, I have an AJAX application that uses MVC Web API as the back end. The client however calls from a different domain and uses a PHP proxy file to get around cross-domain request issues.
However, using the PHP proxy, the Web API responds to certain requests with a 100 Continue
HTTP header and any requests that get this back take excessive time to complete (we're talking up to 2 mins or so) and can also return a non-valid response.
This appears to be a known issue with cURL and the workaround is commonly cited as inserting the below line to remove the expect: 100 header in the cURL request
Unfortunately, the solution seems to be elusive for me:
$headers = getallheaders();
$headers_new = "";
foreach($headers as $title => $body) {
$headers_new[] = $title.": ".$body;
}
//$headers_new[] = 'Expect:';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_new);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:') );
This code works but removes all the other headers (which isn't workable for me as I'm using HTTP basic auth headers to authenticate with the API).
You may also notice I tried adding the Expect:
to the existing headers, but this didn't help me either.
How can I maintain the existing headers, but also prevent cURL from expecting a 100 continue?
See Question&Answers more detail:os