From e5ad620a152692d2738bf67c361004713d6a8707 Mon Sep 17 00:00:00 2001 From: Meeeeow Date: Sat, 22 Apr 2017 16:28:47 +0800 Subject: [PATCH] fix upstream search (registry.npmjs.org) --- lib/index-api.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/index-api.js b/lib/index-api.js index ee706e88d..c624de91d 100644 --- a/lib/index-api.js +++ b/lib/index-api.js @@ -98,7 +98,7 @@ module.exports = function(config, auth, storage) { var received_end = false var response_finished = false var processing_pkgs = 0 - let firstPackage = true + var firstPackage = true res.status(200) @@ -114,13 +114,15 @@ module.exports = function(config, auth, storage) { * See: method 'request' in up-storage.js * * If there is no cache in local, NPM will request /-/all, then get response with - * _updated: 99999, after this, NPM will request /-/all/since with another magic - * number 434592768000 + * _updated: 99999, 'Date' in response header was Mon, 10 Oct 1983 00:12:48 GMT, + * this will make NPM always query from server * * Data structure also different, whel request /-/all, response is an object, but * when request /-/all/since, response is an array */ - const respShouldBeArray = req.path.endsWith('/since') + var respShouldBeArray = req.path.endsWith('/since') + res.set('Date', 'Mon, 10 Oct 1983 00:12:48 GMT') + if (respShouldBeArray) { res.write('[') } else {