如何删除在Javascript中的HTTP特定的头 [英] How to remove HTTP specific headers in Javascript

查看:98
本文介绍了如何删除在Javascript中的HTTP特定的头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能,发送一个HTTP消息之前,用除去一些特定的HTTP标头的JavaScript / XmlHtt prequest?

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

问候

推荐答案

您可以使用XmlHtt prequest对象的setRequestHeader方法,假设你的浏览器支持它,这是的W3C SPEC 它也被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特定的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆