: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.WHATWGFetch = {})));
}(this, (function (exports) { 'use strict';
/* eslint-disable no-prototype-builtins */
(typeof globalThis !== 'undefined' && globalThis) ||
(typeof self !== 'undefined' && self) ||
// eslint-disable-next-line no-undef
(typeof global !== 'undefined' && global) ||
searchParams: 'URLSearchParams' in g,
iterable: 'Symbol' in g && 'iterator' in Symbol,
formData: 'FormData' in g,
arrayBuffer: 'ArrayBuffer' in g
function isDataView(obj) {
return obj && DataView.prototype.isPrototypeOf(obj)
if (support.arrayBuffer) {
'[object Uint8ClampedArray]',
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
function normalizeName(name) {
if (typeof name !== 'string') {
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
throw new TypeError('Invalid character in header field name: "' + name + '"')
return name.toLowerCase()
function normalizeValue(value) {
if (typeof value !== 'string') {
// Build a destructive iterator for the value list
function iteratorFor(items) {
var value = items.shift();
return {done: value === undefined, value: value}
iterator[Symbol.iterator] = function() {
function Headers(headers) {
if (headers instanceof Headers) {
headers.forEach(function(value, name) {
this.append(name, value);
} else if (Array.isArray(headers)) {
headers.forEach(function(header) {
if (header.length != 2) {
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
this.append(header[0], header[1]);
Object.getOwnPropertyNames(headers).forEach(function(name) {
this.append(name, headers[name]);
Headers.prototype.append = function(name, value) {
name = normalizeName(name);
value = normalizeValue(value);
var oldValue = this.map[name];
this.map[name] = oldValue ? oldValue + ', ' + value : value;
Headers.prototype['delete'] = function(name) {
delete this.map[normalizeName(name)];
Headers.prototype.get = function(name) {
name = normalizeName(name);
return this.has(name) ? this.map[name] : null
Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(normalizeName(name))
Headers.prototype.set = function(name, value) {
this.map[normalizeName(name)] = normalizeValue(value);
Headers.prototype.forEach = function(callback, thisArg) {
for (var name in this.map) {
if (this.map.hasOwnProperty(name)) {
callback.call(thisArg, this.map[name], name, this);
Headers.prototype.keys = function() {
this.forEach(function(value, name) {
return iteratorFor(items)
Headers.prototype.values = function() {
this.forEach(function(value) {
return iteratorFor(items)
Headers.prototype.entries = function() {
this.forEach(function(value, name) {
items.push([name, value]);
return iteratorFor(items)
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
function consumed(body) {
return Promise.reject(new TypeError('Already read'))
function fileReaderReady(reader) {
return new Promise(function(resolve, reject) {
reader.onload = function() {
reader.onerror = function() {
function readBlobAsArrayBuffer(blob) {
var reader = new FileReader();
var promise = fileReaderReady(reader);
reader.readAsArrayBuffer(blob);
function readBlobAsText(blob) {
var reader = new FileReader();
var promise = fileReaderReady(reader);
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
var encoding = match ? match[1] : 'utf-8';
reader.readAsText(blob, encoding);
function readArrayBufferAsText(buf) {
var view = new Uint8Array(buf);
var chars = new Array(view.length);
for (var i = 0; i < view.length; i++) {
chars[i] = String.fromCharCode(view[i]);
function bufferClone(buf) {
var view = new Uint8Array(buf.byteLength);
view.set(new Uint8Array(buf));
this._initBody = function(body) {
fetch-mock wraps the Response object in an ES6 Proxy to
provide useful test harness features such as flush. However, on
ES5 browsers without fetch or Proxy support pollyfills must be used;
the proxy-pollyfill is unable to proxy an attribute unless it exists
on the object before the Proxy is created. This change ensures
Response.bodyUsed exists on the instance, while maintaining the
semantic of setting Request.bodyUsed in the constructor before
// eslint-disable-next-line no-self-assign
this.bodyUsed = this.bodyUsed;
} else if (typeof body === 'string') {
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body;
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this._bodyText = body.toString();
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
this._bodyArrayBuffer = bufferClone(body.buffer);
// IE 10-11 can't handle a DataView body.
this._bodyInit = new Blob([this._bodyArrayBuffer]);
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
this._bodyArrayBuffer = bufferClone(body);
this._bodyText = body = Object.prototype.toString.call(body);
if (!this.headers.get('content-type')) {
if (typeof body === 'string') {
this.headers.set('content-type', 'text/plain;charset=UTF-8');
} else if (this._bodyBlob && this._bodyBlob.type) {
this.headers.set('content-type', this._bodyBlob.type);
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
var rejected = consumed(this);
return Promise.resolve(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as blob')
return Promise.resolve(new Blob([this._bodyText]))
this.arrayBuffer = function() {
if (this._bodyArrayBuffer) {
var isConsumed = consumed(this);
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
this._bodyArrayBuffer.buffer.slice(
this._bodyArrayBuffer.byteOffset,
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
return Promise.resolve(this._bodyArrayBuffer)
} else if (support.blob) {
return this.blob().then(readBlobAsArrayBuffer)
throw new Error('could not read as ArrayBuffer')
var rejected = consumed(this);
return readBlobAsText(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as text')
return Promise.resolve(this._bodyText)
this.formData = function() {
return this.text().then(decode)
return this.text().then(JSON.parse)
// HTTP methods whose capitalization should be normalized
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
function normalizeMethod(method) {
var upcased = method.toUpperCase();
return methods.indexOf(upcased) > -1 ? upcased : method
function Request(input, options) {
if (!(this instanceof Request)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
if (input instanceof Request) {
throw new TypeError('Already read')
this.credentials = input.credentials;
this.headers = new Headers(input.headers);
this.method = input.method;
this.signal = input.signal;
if (!body && input._bodyInit != null) {
this.url = String(input);
this.credentials = options.credentials || this.credentials || 'same-origin';
if (options.headers || !this.headers) {
this.headers = new Headers(options.headers);
this.method = normalizeMethod(options.method || this.method || 'GET');
this.mode = options.mode || this.mode || null;
this.signal = options.signal || this.signal || (function () {
if ('AbortController' in g) {
var ctrl = new AbortController();
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
throw new TypeError('Body not allowed for GET or HEAD requests')
if (this.method === 'GET' || this.method === 'HEAD') {
if (options.cache === 'no-store' || options.cache === 'no-cache') {
// Search for a '_' parameter in the query string
var reParamSearch = /([?&])_=[^&]*/;
if (reParamSearch.test(this.url)) {
// If it already exists then set the value with the current time
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
// Otherwise add a new '_' parameter to the end with the current time
var reQueryString = /\?/;
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
Request.prototype.clone = function() {
return new Request(this, {body: this._bodyInit})
var form = new FormData();
.forEach(function(bytes) {
var split = bytes.split('=');
var name = split.shift().replace(/\+/g, ' ');
var value = split.join('=').replace(/\+/g, ' ');
form.append(decodeURIComponent(name), decodeURIComponent(value));
function parseHeaders(rawHeaders) {
var headers = new Headers();
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
// https://tools.ietf.org/html/rfc7230#section-3.2
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
// https://github.com/github/fetch/issues/748
// https://github.com/zloirock/core-js/issues/751
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
.forEach(function(line) {
var parts = line.split(':');
var key = parts.shift().trim();
var value = parts.join(':').trim();
headers.append(key, value);
console.warn('Response ' + error.message);
Body.call(Request.prototype);
function Response(bodyInit, options) {
if (!(this instanceof Response)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
this.status = options.status === undefined ? 200 : options.status;
if (this.status < 200 || this.status > 599) {
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
this.ok = this.status >= 200 && this.status < 300;
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
this.headers = new Headers(options.headers);
this.url = options.url || '';
this._initBody(bodyInit);
Body.call(Response.prototype);
Response.prototype.clone = function() {
return new Response(this._bodyInit, {
statusText: this.statusText,
headers: new Headers(this.headers),
Response.error = function() {