Skip to content

http.js wont follow urls if Location is lowercase

in HTTPRequest.prototype.Get

        if ([301, 302, 307, 308].indexOf(this.response_code) > -1
                && this.follow_redirects > 0
                && this.response_headers_parsed.Location
                && this.response_headers_parsed.Location.length

This only works if Location in the header is uppercase.

Unfortunately, some BBC sites return "location" with lowercase.

As a workaround, I'm forcing the first character of M in HTTPRequest.prototype.ReadHeaders=function()

to be uppercase

                if (m) {
                        m[1] = m[1].charAt(0).toUpperCase() + m[1].slice(1);

I'm not sure if this is the proper fix, but I'm not sure how you would do a case insensitive match on this.response_headers_parsed.Location

I'll leave it to the experts to determine the proper fix.