From 45bb21b9c9ea2b4c7cbfeb29c0e77a6d95f2b345 Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Tue, 30 Dec 2014 13:24:54 +0500 Subject: [PATCH] Change order of comparsions and header check This could speed up most common case (2xx response) --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 8647e35..a0b6161 100644 --- a/index.js +++ b/index.js @@ -59,7 +59,7 @@ function got(url, opts, cb) { var res = response; // redirect - if (statusCode < 400 && statusCode >= 300 && res.headers.location) { + if (statusCode >= 300 && statusCode < 400 && 'location' in res.headers) { if (++redirectCount > 10) { cb(new Error('Redirected 10 times. Aborting.'), undefined, res); return;