Итак, длинный рассказ, у меня есть приложение AJAX, которое использует MVC Web API в качестве задней части. Однако клиент звонит из другого домена и использует файл прокси-сервера PHP, чтобы обойти проблемы междоменного запроса.
Однако, используя прокси-сервер PHP, веб-API отвечает на определенные запросы с заголовком 100 Continue
HTTP, и любые запросы, которые получают это обратно, требуют чрезмерного времени (мы говорим до 2 минут или около того) и можем также возвращает недействительный ответ.
Этот представляет собой известную проблему с cURL, и обходной путь обычно упоминается как вставка строки ниже, чтобы удалить заголовок expect: 100 в запросе cURL
К сожалению, решение кажется мне неуловимым:
$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:') );
Этот код работает, но удаляет все остальные заголовки (что не работает для меня, поскольку я использую HTTP-заголовки auth для аутентификации с помощью API).
Вы также можете заметить, что я попытался добавить Expect:
в существующие заголовки, но это тоже мне не помогло.
Как я могу сохранить существующие заголовки, но также запретить cURL ожидать, что 100 продолжит?