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

Method _header

lib/response.js:152–184  ·  view source on GitHub ↗
(key, value, options = {})

Source from the content-addressed store, hash-verified

150 }
151
152 _header(key, value, options = {}) {
153
154 const append = options.append ?? false;
155 const separator = options.separator || ',';
156 const override = options.override !== false;
157 const duplicate = options.duplicate !== false;
158
159 if (!append && override ||
160 !this.headers[key]) {
161
162 this.headers[key] = value;
163 }
164 else if (override) {
165 if (key === 'set-cookie') {
166 this.headers[key] = [].concat(this.headers[key], value);
167 }
168 else {
169 const existing = this.headers[key];
170 if (!duplicate) {
171 const values = existing.split(separator);
172 for (const v of values) {
173 if (v === value) {
174 return this;
175 }
176 }
177 }
178
179 this.headers[key] = existing + separator + value;
180 }
181 }
182
183 return this;
184 }
185
186 vary(value) {
187

Callers 10

cors.jsFile · 0.80
headers.jsFile · 0.80
security.jsFile · 0.80
transmit.jsFile · 0.80
headerMethod · 0.80
varyMethod · 0.80
etagMethod · 0.80
typeMethod · 0.80
bytesMethod · 0.80
locationMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected