Firefox有一個名爲httprequester的插件。 (https://addons.mozilla.org/en-US/firefox/addon/httprequester/)PHP捲曲頭(?)問題
當我使用插件發送帶有特定cookie的GET請求時,一切正常。
請求頭:
GET https://store.steampowered.com/account/
Cookie: steamLogin=*removed because of obvious reasons*
響應頭:
200 OK
Server: Apache
... (continued, not important)
然後我試圖做同樣的事情與捲曲:
$ch = curl_init("https://store.steampowered.com/account/");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: steamLogin=*removed because of obvious reasons*"));
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
$response = curl_exec($ch);
$request_header = curl_getinfo($ch, CURLINFO_HEADER_OUT);
echo "<pre>$request_header</pre>";
echo "<pre>$response</pre>";
請求頭:
GET /account/ HTTP/1.1
Host: store.steampowered.com
Accept: */*
Cookie: steamLogin=*removed because of obvious reasons*
響應頭:
HTTP/1.1 302 Moved Temporarily
Server: Apache
... (continued, not important)
我不知道是否有任何與我的問題,但我注意到一件事是,請求頭的第一線是不同的
GET https://store.steampowered.com/account/
和
GET /account/ HTTP/1.1
Host: store.steampowered.com
我的問題是,我得到與插件和302捲曲200 HTTP代碼,但我要送(或嘗試發送)相同請求。
讓我直截了當地說,問題是爲什麼請求停在302 HTTP代碼上? –
您似乎忘記提及問題所在。 – marekful
我的問題是,我得到200的HTTP代碼與插件和302捲曲,但我發送(或試圖發送)相同的請求。 – user3210615