MCPcopy Index your code
hub / github.com/hapijs/hapi / encoding

Method encoding

lib/compression.js:85–111  ·  view source on GitHub ↗
(response, length)

Source from the content-addressed store, hash-verified

83 }
84
85 encoding(response, length) {
86
87 if (response.settings.compressed) {
88 response.headers['content-encoding'] = response.settings.compressed;
89 return null;
90 }
91
92 const request = response.request;
93 if (!request._core.settings.compression ||
94 length !== null && length < request._core.settings.compression.minBytes) {
95
96 return null;
97 }
98
99 const mime = request._core.mime.type(response.headers['content-type'] || 'application/octet-stream');
100 if (!mime.compressible) {
101 return null;
102 }
103
104 response.vary('accept-encoding');
105
106 if (response.headers['content-encoding']) {
107 return null;
108 }
109
110 return request.info.acceptEncoding === 'identity' ? null : request.info.acceptEncoding;
111 }
112
113 encoder(request, encoding) {
114

Callers

nothing calls this directly

Calls 2

typeMethod · 0.65
varyMethod · 0.65

Tested by

no test coverage detected