From 8045fc8741cc66a816736dfa6a01f8adb6b202fc Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 27 Jul 2015 01:00:55 +0200 Subject: [PATCH] use `http.STATUS_CODES` ponyfill Since the list differ between Node.js versions: https://github.com/nodejs/io.js/commit/8be6060020 This is different than the previous `statuses` module we used as this is a strict ponyfill for the built-in list. --- index.js | 5 +++-- package.json | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8bac67c..7f59de5 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ var isRedirect = require('is-redirect'); var PinkiePromise = require('pinkie-promise'); var unzipResponse = require('unzip-response'); var createErrorClass = require('create-error-class'); +var nodeStatusCodes = require('node-status-codes'); function requestAsEventEmitter(opts) { opts = opts || {}; @@ -278,14 +279,14 @@ got.ParseError = createErrorClass('ParseError', stdError); got.HTTPError = createErrorClass('HTTPError', function (statusCode, opts) { stdError.call(this, {}, opts); this.statusCode = statusCode; - this.statusMessage = http.STATUS_CODES[this.statusCode]; + this.statusMessage = nodeStatusCodes[this.statusCode]; this.message = 'Response code ' + this.statusCode + ' (' + this.statusMessage + ')'; }); got.MaxRedirectsError = createErrorClass('MaxRedirectsError', function (statusCode, opts) { stdError.call(this, {}, opts); this.statusCode = statusCode; - this.statusMessage = http.STATUS_CODES[this.statusCode]; + this.statusMessage = nodeStatusCodes[this.statusCode]; this.message = 'Redirected 10 times. Aborting.'; }); diff --git a/package.json b/package.json index e00ca26..65b15f3 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "is-redirect": "^1.0.0", "is-stream": "^1.0.0", "lowercase-keys": "^1.0.0", + "node-status-codes": "^1.0.0", "object-assign": "^3.0.0", "pinkie-promise": "^1.0.0", "prepend-http": "^1.0.0",