【发布时间】:2016-12-12 11:31:16
【问题描述】:
这是我的 curl 请求(在一些旧的 stackoverflow 答案中找到):
$headers[] = "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0";
$headers[] = "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$headers[] = "Accept-Language:en-us,en;q=0.5";
$headers[] = "Accept-Encoding:gzip,deflate";
$headers[] = "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$headers[] = "Keep-Alive:115";
$headers[] = "Connection:keep-alive";
$headers[] = "Cache-Control:max-age=0";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
我得到这个错误:
错误请求 - 无效标头
HTTP 错误 400。请求的标头名称无效。
你知道我为什么会收到这个错误吗?我应该如何解决它?
【问题讨论】:
-
我猜你已经看到了:stackoverflow.com/questions/19671317/…?
标签: php servlets curl http-headers http-status-code-404