Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

prevent crash when 302 is returned without location header #276

Closed
wants to merge 1 commit into from

3 participants

@rimar

No description provided.

@cronopio
Collaborator

lgtm

@indexzero
Owner

This should be a typeof response.headers.location !== 'undefined' check

@indexzero indexzero closed this in 013cb2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/node-http-proxy/http-proxy.js
View
4 lib/node-http-proxy/http-proxy.js
@@ -235,10 +235,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
}
if ((response.statusCode === 301) || (response.statusCode === 302)) {
- if (self.source.https && !self.target.https) {
+ if (self.source.https && !self.target.https && response.headers.location != null) {
response.headers.location = response.headers.location.replace(/^http\:/, 'https:');
}
- if (self.target.https && !self.source.https) {
+ if (self.target.https && !self.source.https && response.headers.location != null) {
response.headers.location = response.headers.location.replace(/^https\:/, 'http:');
}
}
Something went wrong with that request. Please try again.