在 XMLHttpRequest 中获取 SENT 标头

get SENT headers in an XMLHttpRequest(在 XMLHttpRequest 中获取 SENT 标头)

本文介绍了在 XMLHttpRequest 中获取 SENT 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图从 XHR 对象中获取请求标头,但没有成功,是否存在该对象的隐藏方法或属性会暴露浏览器发送的标头?

Trying to get the Request headers from the XHR object, but with no luck, is there a hidden method or property of that object that will expose the headers sent by the browser?

我已经知道如何设置自定义请求标头和查看响应标头,我正在寻找发送的所有请求标头的列表,浏览器创建的标头和我的自定义标头.

I already know how to set custom request headers and view the response headers, I'm looking to get a list of all REQUEST headers sent, ones created by the browser and my custom ones.

我用的是webkit/chrome,其他浏览器不用管.

I'm using webkit/chrome, don't care about other browsers.

我不想监控请求,我正在构建一个网络应用程序,我需要列出这些标头并在应用程序中显示它们,请不要告诉我有关 fiddler、firebug 和 chrome 工具的信息,这不是我要找的.

I'm not looking to monitor the request, I'm building a web app and I need to list those headers and display them within the app, please don't tell me about fiddler, firebug and chrome tools, that's not what I'm looking for.

推荐答案

XMLHttpRequest 中没有方法API 获取发送的请求标头.有一些方法可以仅获取响应标头,并设置请求标头.

There is no method in the XMLHttpRequest API to get the sent request headers. There are methods to get the response headers only, and set request headers.

您必须让服务器回显标头,或者使用像 Wireshark 这样的数据包嗅探器.

You'll have to either have the server echo the headers, or use a packet sniffer like Wireshark.

这篇关于在 XMLHttpRequest 中获取 SENT 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 XMLHttpRequest 中获取 SENT 标头

基础教程推荐