2
我想重新使用小數據從一個POST請求的進一步後requests.In以下服務器端代碼,我發現了餅乾作爲JSON對象的響應得到了如何在Meteor的多個帖子請求中保留Cookie?
Meteor.methods({
'login':function(){
var cookieData = "";
var loginUrl = "http://somesite.com/login.page";
var loginData = {params:{username:"myUserName",password:"mySeceret"},headers:{"User-Agent":"Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0"}};
var homePage = HTTP.post(loginUrl,loginData);
var cookieData = homePage.headers["set-cookie"];
var secondPageUrl = "http://somesite.com/scond.page"
var postData = {params:{param1:"value1",param2:"value2"},headers:{Cookie:cookieData,"User-Agent":"Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0"}};
var secondResponse = HTTP.post(secondPageUrl,postData);
}
})
,我發現了secondResponse.statusCode爲302,而不是200
變量cookieData是一個JSON對象,現在如何使用cookieData的進一步POST請求的內容?