MCPcopy
hub / github.com/hapijs/hapi / constructor

Method constructor

lib/response.js:35–71  ·  view source on GitHub ↗
(source, request, options = {})

Source from the content-addressed store, hash-verified

33exports = module.exports = internals.Response = class {
34
35 constructor(source, request, options = {}) {
36
37 this.app = {};
38 this.headers = {}; // Incomplete as some headers are stored in flags
39 this.plugins = {};
40 this.request = request;
41 this.source = null;
42 this.statusCode = null;
43 this.variety = null;
44
45 this.settings = {
46 charset: 'utf-8', // '-' required by IANA
47 compressed: null,
48 encoding: 'utf8',
49 message: null,
50 passThrough: true,
51 stringify: null, // JSON.stringify options
52 ttl: null,
53 varyEtag: false
54 };
55
56 this._events = null;
57 this._payload = null; // Readable stream
58 this._error = options.error ?? null; // The boom object when created from an error (used for logging)
59 this._contentType = null; // Used if no explicit content-type is set and type is known
60 this._takeover = false;
61 this._statusCode = false; // true when code() called
62 this._state = this._error ? 'prepare' : 'init'; // One of 'init', 'prepare', 'marshall', 'close'
63
64 this._processors = {
65 marshal: options.marshal,
66 prepare: options.prepare,
67 close: options.close
68 };
69
70 this._setSource(source, options.variety);
71 }
72
73 static wrap(result, request) {
74

Callers

nothing calls this directly

Calls 3

_setSourceMethod · 0.80
emitMethod · 0.80
onMethod · 0.65

Tested by

no test coverage detected