我試圖在Node中構建一個Google Pagespeed客戶端,但我正在與https客戶端苦苦掙扎。請求總是以302響應返回,但完全相同的網址完全在捲曲和瀏覽器Node.js和Google Pagespeed API
options = {
host: 'https://www.googleapis.com'
, path: '/pagespeedonline/v1/runPagespeed?url=' + program.uri + '/&prettyprint=false&strategy=' + program.strategy + '&key=' + program.key
}
https.get(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
}).on('error', function(e) {
console.error(e);
});
我缺少的東西?試圖發送幾個不同的標題,但它沒有太大的區別
真棒,非常感謝! – 2012-04-18 07:37:29