UNPKG

@mojojs/core

Version:

Real-time web framework

53 lines 1.46 kB
import { Body } from '../body.js'; /** * User-agent response class. */ export class UserAgentResponse extends Body { constructor(options) { super(options.headers, options.body); this.httpVersion = options.httpVersion; this.statusCode = options.statusCode; this.statusMessage = options.statusMessage; } /** * Check if response has a `4xx` response status code. */ get isClientError() { const { statusCode } = this; return statusCode >= 400 && statusCode <= 499; } /** * Check if response has a `4xx` or `5xx` response status code. */ get isError() { return this.isClientError || this.isServerError; } /** * Check if response has a `3xx` response status code. */ get isRedirect() { const { statusCode } = this; return statusCode >= 300 && statusCode <= 399; } /** * Check if response has a `5xx` response status code. */ get isServerError() { const { statusCode } = this; return statusCode >= 500 && statusCode <= 599; } /** * Check if response has a `2xx` response status code. */ get isSuccess() { const { statusCode } = this; return statusCode >= 200 && statusCode <= 299; } /** * Get `Content-Type` header value. */ get type() { return this.get('Content-Type'); } } //# sourceMappingURL=response.js.map