mirror of
				https://github.com/KevinMidboe/moviedb.git
				synced 2025-10-29 17:50:25 +00:00 
			
		
		
		
	Add etag and if-modified-since support. (http request)
The execMethod() returns a third parameter which is the http response. (In order to get the date and the etag header values)
This commit is contained in:
		| @@ -86,6 +86,17 @@ var execMethod = function(type, params, endpoint, fn){ | |||||||
|             .query({api_key : this.api_key}) |             .query({api_key : this.api_key}) | ||||||
|             .set('Accept', 'application/json'); |             .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') |   if(type === 'GET') | ||||||
|     req.query(params); |     req.query(params); | ||||||
|   else |   else | ||||||
| @@ -93,9 +104,9 @@ var execMethod = function(type, params, endpoint, fn){ | |||||||
|  |  | ||||||
|   req.end(function(err, res){ |   req.end(function(err, res){ | ||||||
|     if(err){ |     if(err){ | ||||||
|       fn(err); |       fn(err, null, res); | ||||||
|     } else { |     } else { | ||||||
|       fn(null, res.body); |       fn(null, res.body, res); | ||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user