Socket
Socket
Sign inDemoInstall

xmlhttprequest

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmlhttprequest - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

51

lib/XMLHttpRequest.js

@@ -45,3 +45,4 @@ /**

var headers = defaultHeaders;
var headers = {};
var headersCase = {};

@@ -114,2 +115,6 @@ // These headers are not user setable.

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

@@ -159,3 +164,3 @@ /**

if (!isAllowedHttpMethod(method)) {
throw "SecurityError: Request method not allowed";
throw new Error("SecurityError: Request method not allowed");
}

@@ -185,3 +190,3 @@

/**
* Sets a header for the request.
* Sets a header for the request or appends the value if one is already set.
*

@@ -193,3 +198,3 @@ * @param string header Header name

if (this.readyState !== this.OPENED) {
throw "INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN";
throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");
}

@@ -201,5 +206,7 @@ if (!isAllowedHttpHeader(header)) {

if (sendFlag) {
throw "INVALID_STATE_ERR: send flag is true";
throw new Error("INVALID_STATE_ERR: send flag is true");
}
headers[header] = value;
header = headersCase[header.toLowerCase()] || header;
headersCase[header.toLowerCase()] = header;
headers[header] = headers[header] ? headers[header] + ', ' + value : value;
};

@@ -254,5 +261,4 @@

this.getRequestHeader = function(name) {
// @TODO Make this case insensitive
if (typeof name === "string" && headers[name]) {
return headers[name];
if (typeof name === "string" && headersCase[name.toLowerCase()]) {
return headers[headersCase[name.toLowerCase()]];
}

@@ -270,7 +276,7 @@

if (this.readyState !== this.OPENED) {
throw "INVALID_STATE_ERR: connection must be opened before send() is called";
throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");
}
if (sendFlag) {
throw "INVALID_STATE_ERR: send has already been called";
throw new Error("INVALID_STATE_ERR: send has already been called");
}

@@ -295,2 +301,3 @@

case undefined:
case null:
case "":

@@ -301,3 +308,3 @@ host = "localhost";

default:
throw "Protocol not supported.";
throw new Error("Protocol not supported.");
}

@@ -308,3 +315,3 @@

if (settings.method !== "GET") {
throw "XMLHttpRequest: Only GET method is supported";
throw new Error("XMLHttpRequest: Only GET method is supported");
}

@@ -341,2 +348,9 @@

// Set the defaults if they haven't been set
for (var name in defaultHeaders) {
if (!headersCase[name.toLowerCase()]) {
headers[name] = defaultHeaders[name];
}
}
// Set the Host header or the server may reject the request

@@ -378,3 +392,4 @@ headers.Host = host;

headers: headers,
agent: false
agent: false,
withCredentials: self.withCredentials
};

@@ -415,3 +430,4 @@

method: response.statusCode === 303 ? "GET" : settings.method,
headers: headers
headers: headers,
withCredentials: self.withCredentials
};

@@ -526,3 +542,3 @@

this.handleError = function(error) {
this.status = 503;
this.status = 0;
this.statusText = error;

@@ -532,2 +548,3 @@ this.responseText = error.stack;

setState(this.DONE);
this.dispatchEvent('error');
};

@@ -545,2 +562,3 @@

headers = defaultHeaders;
this.status = 0;
this.responseText = "";

@@ -558,2 +576,3 @@ this.responseXML = "";

this.readyState = this.UNSENT;
this.dispatchEvent('abort');
};

@@ -560,0 +579,0 @@

{
"name": "xmlhttprequest",
"description": "XMLHttpRequest for Node",
"version": "1.7.0",
"version": "1.8.0",
"author": {

@@ -10,6 +10,3 @@ "name": "Dan DeFelippi",

"keywords": ["xhr", "ajax"],
"licenses": [{
"type": "MIT",
"url": "http://creativecommons.org/licenses/MIT/"
}],
"license": "MIT",
"repository": {

@@ -16,0 +13,0 @@ "type": "git",

@@ -54,5 +54,3 @@ # node-XMLHttpRequest #

* Some events are missing, such as abort
* getRequestHeader is case-sensitive
* Cookies aren't persisted between requests
* Missing XML support
* Missing basic auth
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc