我試圖倍率prototype.js
通過與continue;
添加在setRequestHeaders
功能if()
避免指定部首:的Prototype.js 1.4.0拋出「拒絕設置不安全標題‘連接’」錯誤
for (var i = 0; i < requestHeaders.length; i += 2){
if("Connection" === requestHeaders[i] || "Connection" === requestHeaders[i+1])
continue;
this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
}
在IE9上這個工作正常,沒有修改到prototype.js
,但是在其他瀏覽器(Chrome,Firefox等)中出現錯誤標題..
感謝您的任何建議和幫助! :)
[編輯]
工作重複的問題: 我發現這個話題,但它不是一樣的。在重複的主題中有一個可以修改的文件,但我不能修改prototype.js
的代碼。
[EDIT2]
此代碼是在1.4.0(如寫入標題),線約661-685
setRequestHeaders: function() {
var requestHeaders =
['X-Requested-With', 'XMLHttpRequest',
'X-Prototype-Version', Prototype.Version];
if (this.options.method == 'post') {
requestHeaders.push('Content-type',
'application/x-www-form-urlencoded');
/* Force "Connection: close" for Mozilla browsers to work around
* a bug where XMLHttpReqeuest sends an incorrect Content-length
* header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType)
requestHeaders.push('Connection', 'close');
}
if (this.options.requestHeaders)
requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
for (var i = 0; i < requestHeaders.length; i += 2){
console.log(requestHeaders[i] + " AND " + requestHeaders[i+1]);
//My edition - BEGIN;
if("Connection" === requestHeaders[i] || "Connection" === requestHeaders[i+1])
continue;
//END;
this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
}
}
謝謝! :)
什麼是'.equals(...)'?這當然不是Javascript ... – Tomalak
是的,它是@Tomalak – epascarello
@epascarello不,它不是。在規格中告訴我。 – Tomalak