Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions example/eventsource-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -3764,7 +3764,7 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, f
self.url = response.url
self.statusCode = response.status
self.statusMessage = response.statusText

response.headers.forEach(function (header, key){
self.headers[key.toLowerCase()] = header
self.rawHeaders.push(key, header)
Expand Down Expand Up @@ -3894,7 +3894,7 @@ IncomingMessage.prototype._onXHRProgress = function () {
self.push(new Buffer(response))
break
}
// Falls through in IE8
// Falls through in IE8
case 'text':
try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
response = xhr.responseText
Expand Down Expand Up @@ -6457,7 +6457,7 @@ function EventSource (url, eventSourceInitDict) {
}

// Handle HTTP redirects
if (res.statusCode === 301 || res.statusCode === 307) {
if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) {
if (!res.headers.location) {
// Server sent redirect response without Location header.
_emit('error', new Event('error', {status: res.statusCode}))
Expand Down Expand Up @@ -10085,4 +10085,4 @@ if (typeof Object.create === 'function') {


/***/ })
/******/ ]);
/******/ ]);
2 changes: 1 addition & 1 deletion lib/eventsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function EventSource (url, eventSourceInitDict) {
}

// Handle HTTP redirects
if (res.statusCode === 301 || res.statusCode === 307) {
if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) {
if (!res.headers.location) {
// Server sent redirect response without Location header.
_emit('error', new Event('error', {status: res.statusCode, message: res.statusMessage}))
Expand Down
2 changes: 1 addition & 1 deletion test/eventsource_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ describe('HTTP Request', function () {
})
});

[301, 307].forEach(function (status) {
[301, 302, 307].forEach(function (status) {
it('follows http ' + status + ' redirect', function (done) {
var redirectSuffix = '/foobar'
var clientRequestedRedirectUrl = false
Expand Down