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

.abort: Don't set headers to default #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions lib/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ exports.XMLHttpRequest = function() {
this.responseXML = "";
this.status = null;
this.statusText = null;

// Whether cross-site Access-Control requests should be made using
// credentials such as cookies or authorization headers
this.withCredentials = false;
this.rejectUnauthorized = false;

/**
* Private methods
Expand Down Expand Up @@ -378,7 +379,8 @@ exports.XMLHttpRequest = function() {
method: settings.method,
headers: headers,
agent: false,
withCredentials: self.withCredentials
withCredentials: self.withCredentials,
rejectUnauthorized: self.rejectUnauthorized
};

// Reset error flag
Expand Down Expand Up @@ -415,7 +417,8 @@ exports.XMLHttpRequest = function() {
path: url.path,
method: response.statusCode === 303 ? "GET" : settings.method,
headers: headers,
withCredentials: self.withCredentials
withCredentials: self.withCredentials,
rejectUnauthorized: self.rejectUnauthorized
};

// Issue the new request
Expand Down Expand Up @@ -542,7 +545,7 @@ exports.XMLHttpRequest = function() {
request = null;
}

headers = defaultHeaders;
headers = {};
this.status = 0;
this.responseText = "";
this.responseXML = "";
Expand Down
2 changes: 1 addition & 1 deletion tests/test-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ try {
// Invalid header
xhr.setRequestHeader("Content-Length", 0);
// Allowed header outside of specs
xhr.setRequestHeader("user-agent", "node-XMLHttpRequest-test");
xhr.setRequestHeader("User-Agent", "node-XMLHttpRequest-test");
// Test getRequestHeader
assert.equal("Foobar", xhr.getRequestHeader("X-Test"));
assert.equal("Foobar", xhr.getRequestHeader("x-tEST"));
Expand Down