本文介紹了如何在 Javascript 中刪除 HTTP 特定的標頭的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
是否可以在發送 http 消息之前使用 javascript/XmlHttpRequest 刪除一些特定的 http 標頭?
Is it possible to, before sending a http message, remove some specific http headers using javascript / XmlHttpRequest ?
我使用的是專有瀏覽器,因此無法使用特定于瀏覽器的解決方案.
I'm using a proprietary browser, so there's no way to do it using browser specific solution.
例如,我想在發送消息之前刪除標題授權"
For example, I want to remove the header 'Authorization' before send the message
POST /social/rpc?oauth_version=1.0& ... HTTP/1.1
Accept: text/html, image/png, image/*, */*
Accept-Language: ko
Authorization: Basic Og==
Host: test.myhost.com
問候
推薦答案
假設您的瀏覽器支持,您可以使用 XmlHttpRequest 對象的 setRequestHeader 方法,它是 W3C 規范.IE也實現了.
You could use the setRequestHeader method of the XmlHttpRequest object assuming your browser supports it, It is part of the W3C spec. It is also implemented by IE.
var req = new XMLHttpRequest();
req.setRequestHeader("Authorization", "");
這篇關于如何在 Javascript 中刪除 HTTP 特定的標頭的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!