通常,当您尝试加载重定向时,您会获得“不可能的数据倒带”。我认为您不能与“关注重定向”选项团结起来。
我不知道洋红色CMS,所以我无法告诉您如何纠正此问题。对于您的cookie问题,这很简单:您只需要从第一个通话中拦截标题“ set-cookie”,然后在下一个呼叫中将带有“ cookie”的标头发送回:
#pragma strict
import System.Collections.Generic;
var url:String = "";
var cookie:String = "";
/// interface
private var stringToEdit:String = "";
function OnGUI(){
if (url!="" && GUI.Button(Rect(10,10,200,30),"Click"))
StartCoroutine(LoadData());
stringToEdit = GUI.TextArea (Rect (10, 50, 600, 400), stringToEdit);
}
/// debug
function Debug(s:String){
stringToEdit += s+"\n";
}
function LoadData():IEnumerator{
Debug(url);
var form : WWWForm = new WWWForm();
var time:String = System.DateTime.Now.Ticks.ToString();
form.AddField("time", time);
// construct your header calls
var headers : Hashtable = form.headers;
if(cookie!="")
headers["Cookie"] = cookie;
var www : WWW = new WWW(url, form.data, headers);
yield www;
if(!www.error){
Debug(www.text);
// get the cookie and keep it
if(www.responseHeaders.ContainsKey('SET-COOKIE')){
var data:String[] = www.responseHeaders['SET-COOKIE'].Split(";"[0]);
if(data.length>0){
cookie = data[0];
}
}
}else
Debug(www.error);
// debug
for(var header:KeyValuePair.<String, String> in www.responseHeaders)
Debug(header.Key+" "+header.Value);
}