This module provides utilites for evaluating conditional requests (as defined in RFC 7232)
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install http-preconditions
var precondition = require('http-preconditions')
req
nodejs request object
The precondition
constructor take an options
argument which should be any one
of the following
when set to true
, enable weak etag comparison. Defaults to false
String value represents the resources etag metadata.
Resource last-modified date as http-date string
var precondition = require('http-preconditions')
var precondition = new precondition(req, {weak: true, etag: 'W/blahblahblah'})
Returns the result of evaluating the preconditions in the request
var precondition = require('http-preconditions')
var precondition = new precondition(req, {weak: true, etag: 'W/blahblahblah'})
if (precondition.condition) {
res.status(200)
}
Returns true
if request contains an if-range
precondition header field
Return true
if request is a cache revalidation request
Returns true
if request is a conditional request