mikeal/request — pull request #1217 by mtetlow (2014-10-26 03:20:30+00:00)
Title: Added check for originalHost before splitting

I encountered an issue when following all redirects on a request:

../node_modules/request/request.js:1195
if (self.uri.hostname !== self.originalHost.split(':')[0]) {
^
TypeError: Cannot call method 'split' of undefined
at Request.onRequestResponse (../node_modules/request/request.js:1195:53)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1688:21)
at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
at Socket.socketOnData [as ondata] (http.js:1583:20)
at TCP.onread (net.js:527:27)

Upon further debugging, it appeared that self.originalHost was undefined at one point in the series of redirects, a simple check for self.originalHost seems to have resolved this issue.