Skip to content

Commit

Permalink
add check for content-type eligrey#73
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit-gohri committed May 16, 2019
1 parent b4f086d commit 6b8e698
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,16 @@
/********************************************************/
var _send = global.XMLHttpRequest && global.XMLHttpRequest.prototype.send
if (_send) {
var _setRequestHeader = XMLHttpRequest.prototype.setRequestHeader;

XMLHttpRequest.prototype.setRequestHeader = function (name, value) {
if (name.toLowerCase() === 'content-type') this._hasContentType = true;
_setRequestHeader.call(this, name, value);
}

XMLHttpRequest.prototype.send = function (data) {
if (data instanceof Blob) {
this.setRequestHeader('Content-Type', data.type)
if (!this._hasContentType) this.setRequestHeader('Content-Type', data.type)
_send.call(this, textDecode(data._buffer))
} else {
_send.call(this, data)
Expand All @@ -516,9 +523,16 @@
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6047383
var _send = global.XMLHttpRequest && global.XMLHttpRequest.prototype.send
if (isIE && _send) {
var _setRequestHeader = XMLHttpRequest.prototype.setRequestHeader;

XMLHttpRequest.prototype.setRequestHeader = function (name, value) {
if (name.toLowerCase() === 'content-type') this._hasContentType = true;
_setRequestHeader.call(this, name, value);
}

XMLHttpRequest.prototype.send = function (data) {
if (data instanceof Blob) {
this.setRequestHeader('Content-Type', data.type)
if (!this._hasContentType) this.setRequestHeader('Content-Type', data.type)
_send.call(this, data)
} else {
_send.call(this, data)
Expand Down

0 comments on commit 6b8e698

Please sign in to comment.