get SENT headers in an XMLHttpRequest get SENT headers in an XMLHttpRequest google-chrome google-chrome

get SENT headers in an XMLHttpRequest


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.

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


Try using Fiddler Web Debugger.

http://www.fiddler2.com/fiddler2/

You can capture the request that was sent in any browser as well as inspect the request headers, response headers, and even copy a capture sent request and send it out as your own.


Assuming you are using jQuery, and you're looking for anything attached, but maybe not ALL headers sent, this could help. Not sure if it meets your exact needs, (since the browser tends to add its own things), but if you need to grab your own headers first, this works:

$.ajaxSetup({    beforeSend: function (jqXHR, settings) {        if(!(settings.headers && settings.headers.token)) {            //no token header was set, so set the request header            jqXHR.setRequestHeader('token', newtoken);        }    }})