Comparing version 4.0.0 to 4.0.1
@@ -166,39 +166,41 @@ 'use strict'; | ||
if (request.headers.range && length) { | ||
if (request.route.settings.response.ranges !== false) { // Backwards compatible comparison | ||
if (request.headers.range && length) { | ||
// Check If-Range | ||
// Check If-Range | ||
if (!request.headers['if-range'] || | ||
request.headers['if-range'] === response.headers.etag) { // Ignoring last-modified date (weak) | ||
if (!request.headers['if-range'] || | ||
request.headers['if-range'] === response.headers.etag) { // Ignoring last-modified date (weak) | ||
// Check that response is not encoded once transmitted | ||
// Check that response is not encoded once transmitted | ||
const mime = request.server.mime.type(response.headers['content-type'] || 'application/octet-stream'); | ||
const encoding = (request.connection.settings.compression && mime.compressible && !response.headers['content-encoding'] ? request.info.acceptEncoding : null); | ||
const mime = request.server.mime.type(response.headers['content-type'] || 'application/octet-stream'); | ||
const encoding = (request.connection.settings.compression && mime.compressible && !response.headers['content-encoding'] ? request.info.acceptEncoding : null); | ||
if (encoding === 'identity' || !encoding) { | ||
if (encoding === 'identity' || !encoding) { | ||
// Parse header | ||
// Parse header | ||
const ranges = Ammo.header(request.headers.range, length); | ||
if (!ranges) { | ||
const error = Boom.rangeNotSatisfiable(); | ||
error.output.headers['content-range'] = 'bytes */' + length; | ||
return callback(error); | ||
} | ||
const ranges = Ammo.header(request.headers.range, length); | ||
if (!ranges) { | ||
const error = Boom.rangeNotSatisfiable(); | ||
error.output.headers['content-range'] = 'bytes */' + length; | ||
return callback(error); | ||
} | ||
// Prepare transform | ||
// Prepare transform | ||
if (ranges.length === 1) { // Ignore requests for multiple ranges | ||
range = ranges[0]; | ||
response.code(206); | ||
response.bytes(range.to - range.from + 1); | ||
response.header('content-range', 'bytes ' + range.from + '-' + range.to + '/' + length); | ||
if (ranges.length === 1) { // Ignore requests for multiple ranges | ||
range = ranges[0]; | ||
response.code(206); | ||
response.bytes(range.to - range.from + 1); | ||
response.header('content-range', 'bytes ' + range.from + '-' + range.to + '/' + length); | ||
} | ||
} | ||
} | ||
} | ||
response.header('accept-ranges', 'bytes'); | ||
} | ||
response.header('accept-ranges', 'bytes'); | ||
return callback(null, range); | ||
@@ -205,0 +207,0 @@ }; |
{ | ||
"name": "inert", | ||
"description": "Static file and directory handlers plugin for hapi.js", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"repository": "git://github.com/hapijs/inert", | ||
@@ -26,3 +26,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"code": "2.x.x", | ||
"code": "3.x.x", | ||
"hapi": "13.x.x", | ||
@@ -29,0 +29,0 @@ "lab": "10.x.x" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
4
1
32553
8
472