MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / Body

Function Body

packages/core/fetch/index.mjs:212–315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210 }
211
212 function Body() {
213 this.bodyUsed = false;
214
215 this._initBody = function (body) {
216 this._bodyInit = body;
217 if (!body) {
218 this._bodyText = "";
219 } else if (typeof body === "string") {
220 this._bodyText = body;
221 } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
222 this._bodyBlob = body;
223 } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
224 this._bodyFormData = body;
225 } else if (
226 support.searchParams &&
227 URLSearchParams.prototype.isPrototypeOf(body)
228 ) {
229 this._bodyText = body.toString();
230 } else if (support.arrayBuffer && support.blob && isDataView(body)) {
231 this._bodyArrayBuffer = bufferClone(body.buffer);
232 // IE 10-11 can't handle a DataView body.
233 this._bodyInit = new Blob([this._bodyArrayBuffer]);
234 } else if (
235 support.arrayBuffer &&
236 (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))
237 ) {
238 this._bodyArrayBuffer = bufferClone(body);
239 } else {
240 this._bodyText = body = Object.prototype.toString.call(body);
241 }
242
243 if (!this.headers.get("content-type")) {
244 if (typeof body === "string") {
245 this.headers.set("content-type", "text/plain;charset=UTF-8");
246 } else if (this._bodyBlob && this._bodyBlob.type) {
247 this.headers.set("content-type", this._bodyBlob.type);
248 } else if (
249 support.searchParams &&
250 URLSearchParams.prototype.isPrototypeOf(body)
251 ) {
252 this.headers.set(
253 "content-type",
254 "application/x-www-form-urlencoded;charset=UTF-8"
255 );
256 }
257 }
258 };
259
260 if (support.blob) {
261 this.blob = function () {
262 var rejected = consumed(this);
263 if (rejected) {
264 return rejected;
265 }
266
267 if (this._bodyBlob) {
268 return Promise.resolve(this._bodyBlob);
269 } else if (this._bodyArrayBuffer) {

Callers

nothing calls this directly

Calls 11

isDataViewFunction · 0.85
bufferCloneFunction · 0.85
consumedFunction · 0.85
readBlobAsTextFunction · 0.85
readArrayBufferAsTextFunction · 0.85
resolveMethod · 0.80
getMethod · 0.65
toStringMethod · 0.45
callMethod · 0.45
setMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected