Merge pull request #40 from oeuillot/master

Add etag and if-modified-since support.
This commit is contained in:
Dan Zajdband
2016-03-14 12:58:57 -04:00

View File

@@ -86,6 +86,17 @@ var execMethod = function(type, params, endpoint, fn){
.query({api_key : this.api_key})
.set('Accept', 'application/json');
if (params.ifNoneMatch) {
req=req.set('If-None-Match', params.ifNoneMatch);
} else if (params.ifModifiedSince) {
var t=params.ifModifiedSince;
if (t.toUTCString) {
t=t.toUTCString();
}
req=req.set('If-Modified-Since', t);
}
if(type === 'GET')
req.query(params);
else
@@ -93,9 +104,9 @@ var execMethod = function(type, params, endpoint, fn){
req.end(function(err, res){
if(err){
fn(err);
fn(err, null, res);
} else {
fn(null, res.body);
fn(null, res.body, res);
}
});
};