Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return the original or redirected URL (if there was a redirect) #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion lib/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ exports.XMLHttpRequest = function() {
// Result & response
this.responseText = "";
this.responseXML = "";
this.responseURL = "";
this.status = null;
this.statusText = null;

Expand Down Expand Up @@ -169,6 +170,8 @@ exports.XMLHttpRequest = function() {
"user": user || null,
"password": password || null
};

this.responseURL = url;

setState(this.OPENED);
};
Expand Down Expand Up @@ -408,7 +411,7 @@ exports.XMLHttpRequest = function() {
// @TODO Prevent looped redirects
if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
// Change URL to the redirect location
settings.url = response.headers.location;
self.responseURL = settings.url = response.headers.location;
var url = Url.parse(settings.url);
// Set host var in case it's used later
host = url.hostname;
Expand Down