@opra/client
Version:
Opra Client package
28 lines (27 loc) • 938 B
JavaScript
"use strict";
/// <reference lib="dom" />
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpResponse = void 0;
class HttpResponse {
constructor(init) {
/**
* Returns true if response has body to be received
*/
this.hasBody = false;
this.headers =
init?.headers instanceof Headers
? init?.headers
: new Headers(init?.headers);
this.status = init?.status || 200;
this.statusText = init?.statusText || 'OK';
this.url = init?.url || null;
this.ok = this.status >= 200 && this.status < 300;
this.body = init?.body;
this.hasBody = init?.body != null || !!init?.hasBody;
this.contentType = (this.headers.get('content-type') || '').split(';')[0];
}
clone(update) {
return new HttpResponse({ ...this, ...update });
}
}
exports.HttpResponse = HttpResponse;