Skip to content

Commit 5eddcc5

Browse files
committed
Prevent updatedb script crash on non-200 response code from maxmind.com
1 parent a75e9a0 commit 5eddcc5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
/node_modules
22
/tmp
3-
npm-debug.log
3+
npm-debug.log
4+
5+
# JetBrains IDE project files
6+
/.idea/

scripts/updatedb.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
var user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.36 Safari/537.36';
66

77
var fs = require('fs');
8+
var http = require('http');
89
var https = require('https');
910
var path = require('path');
1011
var url = require('url');
@@ -160,7 +161,7 @@ function check(database, cb) {
160161
var status = response.statusCode;
161162

162163
if (status !== 200) {
163-
console.log('ERROR'.red + ': HTTP Request Failed [%d %s]', status, https.STATUS_CODES[status]);
164+
console.log('ERROR'.red + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]);
164165
client.abort();
165166
process.exit();
166167
}
@@ -221,7 +222,7 @@ function fetch(database, cb) {
221222
var status = response.statusCode;
222223

223224
if (status !== 200) {
224-
console.log('ERROR'.red + ': HTTP Request Failed [%d %s]', status, https.STATUS_CODES[status]);
225+
console.log('ERROR'.red + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]);
225226
client.abort();
226227
process.exit();
227228
}

0 commit comments

Comments
 (0)