Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Recognize 303, 307 and 308 and do not crash on malformed responses #361

Rob--W opened this Issue · 3 comments

3 participants


This part of the code needs to be changed:


    var statusCode = response.statusCode;
    if (statusCode === 301 || statusCode === 302 || statusCode === 303 || statusCode === 307 || statusCode === 308) {
      if (self.source.https && ! {
        response.headers.location = (response.headers.location || '').replace(/^http:/, 'https:');
      if ( && !self.source.https) {
        response.headers.location = (response.headers.location || '').replace(/^https:/, 'http:');

The changes are:

  1. Status code 303, 307 and 308 are recognized and correctly rewritten.
  2. When some stupid server does not include the Location header with the status, the server will still stay alive (opposed to crashing with message "Cannot call method 'replace' of undefined")

(and a minor change: Removed the backslash before the colon in the RegExp)


this patch, works for me, thanks!


Why would it not be accepted by upsteam??


The existence-check of the location header has already been added some time ago:

Though 307 and 308 redirects are still not supported. Are you referring to that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.