0

I need to get headers when readyState is 4.

I have had this code:

    <script type='text/javascript'>
        var open = window.XMLHttpRequest.prototype.open,
            send = window.XMLHttpRequest.prototype.send,
            onReadyStateChange;

        var sendReplacement = function(data) {
            console.log('Sending HTTP request data : ', data);

            if (this.onreadystatechange) {
                this._onreadystatechange = this.onreadystatechange;
            }
            this.onreadystatechange = onReadyStateChangeReplacement;

            return send.apply(this, arguments);
        };

        var onReadyStateChangeReplacement = function() {
// GET HEADERS
            console.log('HTTP request ready state changed : ' + this.readyState);
            if (this._onreadystatechange) {
                return this._onreadystatechange.apply(this, arguments);
            }
        };

        window.XMLHttpRequest.prototype.send = sendReplacement;

    </script>

Is it possible?

Eric Citaire
  • 4,355
  • 1
  • 29
  • 49
Mediator
  • 14,951
  • 35
  • 113
  • 191

1 Answers1

0

You can use getResponseHeader().

alex
  • 479,566
  • 201
  • 878
  • 984