如下面的代码片段所示,我试图从在XMLHttpRequest上进行的第一次调用获得的响应中提取一个标记。然后我想在第二次POST调用中发送令牌,确保cookie是相同的。但是,我还没有找到保留cookie的方法。有人可以分享我在这里失踪的东西吗?
pipeline = [{'$match':{'creation':{'$lte': {'$date': "2016-01-01T00:00:00Z" }}}}]
df_pipeline = sqlContext.read.format("com.mongodb.spark.sql.DefaultSource")
.option("pipeline", pipeline).load()
df_pipeline.first()
//First XMLHttpRequest below xhr = new XHR(); xhr.onreadystatechange = extractLoginToken; xhr.open( "GET", url );
xhr.setRequestHeader('Set-Cookie', "abc");
xhr.withCredentials = true; xhr.send(); function extractLoginToken() { var params = "token=" + this.responseText.query.token;
var cookie = xhr.getResponseHeader('Set-Cookie');
//Second call xhr = new XHR(); xhr.withCredentials = true; xhr.open( 'POST', url_1 );
xhr.setRequestHeader('Set-Cookie', cookie);