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

Method _loadResponse

packages/core/xhr/index.ts:107–136  ·  view source on GitHub ↗
(r: HttpResponse)

Source from the content-addressed store, hash-verified

105 }
106
107 private _loadResponse(r: HttpResponse) {
108 this._status = r.statusCode;
109 this._headers = r.headers;
110 this._setReadyState(this.HEADERS_RECEIVED);
111
112 this._setReadyState(this.LOADING);
113
114 this._responseTextReader = () => r.content.toString();
115
116 const contentType = this.getResponseHeader('Content-Type');
117 const mimeType = (contentType && contentType.toLowerCase()) || 'text/xml';
118 const finalMimeType = this._overrideMimeType || mimeType;
119
120 if (this._responseType === XMLHttpRequestResponseType.json) {
121 this._response = r.content.toJSON();
122 } else if (this._responseType === XMLHttpRequestResponseType.text || this._responseType === XMLHttpRequestResponseType.empty) {
123 this._response = this.responseText;
124 } else if (this._responseType === XMLHttpRequestResponseType.arraybuffer) {
125 this._response = r.content.toArrayBuffer();
126 } else if (this._responseType === XMLHttpRequestResponseType.blob) {
127 this._response = new Blob([r.content.toArrayBuffer()], {
128 type: finalMimeType,
129 });
130 }
131
132 this.emitEvent('progress');
133
134 this._sendFlag = false;
135 this._setReadyState(this.DONE);
136 }
137
138 private emitEvent(eventName: string, ...args: Array<any>) {
139 if (isFunction(this['on' + eventName])) {

Calls 5

_setReadyStateMethod · 0.95
getResponseHeaderMethod · 0.95
emitEventMethod · 0.95
toJSONMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected