()
| 40945 | } |
| 40946 | |
| 40947 | function Body() { |
| 40948 | this.bodyUsed = false |
| 40949 | |
| 40950 | this._initBody = function(body) { |
| 40951 | this._bodyInit = body |
| 40952 | if (!body) { |
| 40953 | this._bodyText = '' |
| 40954 | } else if (typeof body === 'string') { |
| 40955 | this._bodyText = body |
| 40956 | } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { |
| 40957 | this._bodyBlob = body |
| 40958 | } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { |
| 40959 | this._bodyFormData = body |
| 40960 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { |
| 40961 | this._bodyText = body.toString() |
| 40962 | } else if (support.arrayBuffer && support.blob && isDataView(body)) { |
| 40963 | this._bodyArrayBuffer = bufferClone(body.buffer) |
| 40964 | // IE 10-11 can't handle a DataView body. |
| 40965 | this._bodyInit = new Blob([this._bodyArrayBuffer]) |
| 40966 | } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { |
| 40967 | this._bodyArrayBuffer = bufferClone(body) |
| 40968 | } else { |
| 40969 | throw new Error('unsupported BodyInit type') |
| 40970 | } |
| 40971 | |
| 40972 | if (!this.headers.get('content-type')) { |
| 40973 | if (typeof body === 'string') { |
| 40974 | this.headers.set('content-type', 'text/plain;charset=UTF-8') |
| 40975 | } else if (this._bodyBlob && this._bodyBlob.type) { |
| 40976 | this.headers.set('content-type', this._bodyBlob.type) |
| 40977 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { |
| 40978 | this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') |
| 40979 | } |
| 40980 | } |
| 40981 | } |
| 40982 | |
| 40983 | if (support.blob) { |
| 40984 | this.blob = function() { |
| 40985 | var rejected = consumed(this) |
| 40986 | if (rejected) { |
| 40987 | return rejected |
| 40988 | } |
| 40989 | |
| 40990 | if (this._bodyBlob) { |
| 40991 | return Promise.resolve(this._bodyBlob) |
| 40992 | } else if (this._bodyArrayBuffer) { |
| 40993 | return Promise.resolve(new Blob([this._bodyArrayBuffer])) |
| 40994 | } else if (this._bodyFormData) { |
| 40995 | throw new Error('could not read FormData body as blob') |
| 40996 | } else { |
| 40997 | return Promise.resolve(new Blob([this._bodyText])) |
| 40998 | } |
| 40999 | } |
| 41000 | |
| 41001 | this.arrayBuffer = function() { |
| 41002 | if (this._bodyArrayBuffer) { |
| 41003 | return consumed(this) || Promise.resolve(this._bodyArrayBuffer) |
| 41004 | } else { |
nothing calls this directly
no test coverage detected