Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-providers-http

Package Overview
Dependencies
Maintainers
2
Versions
458
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-providers-http - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

README.md

24

package.json
{
"name": "web3-providers-http",
"version": "1.1.0",
"description": "Module to handle web3 RPC connections over HTTP.",
"repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-providers-http",
"license": "LGPL-3.0",
"main": "src/index.js",
"dependencies": {
"web3-core-helpers": "^1.1.0",
"xmlhttprequest": "*",
"xhr2": "*"
}
"name": "web3-providers-http",
"version": "1.2.0",
"description": "Module to handle web3 RPC connections over HTTP.",
"repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-http",
"license": "LGPL-3.0",
"engines": {
"node": ">=8.0.0 <=11.15.0"
},
"main": "src/index.js",
"dependencies": {
"web3-core-helpers": "1.2.0",
"xhr2-cookies": "1.1.0"
}
}

@@ -19,5 +19,5 @@ /*

* @authors:
* Marek Kotewicz <marek@ethdev.com>
* Marian Oancea <marian@ethdev.com>
* Fabian Vogelsteller <fabian@ethdev.com>
* Marek Kotewicz <marek@parity.io>
* Marian Oancea
* Fabian Vogelsteller <fabian@ethereum.org>
* @date 2015

@@ -27,14 +27,49 @@ */

var errors = require('web3-core-helpers').errors;
var XHR2 = require('xhr2'); // jshint ignore: line
var XHR2 = require('xhr2-cookies').XMLHttpRequest // jshint ignore: line
var http = require('http');
var https = require('https');
/**
* HttpProvider should be used to send rpc calls over http
*/
var HttpProvider = function HttpProvider(host, timeout) {
var HttpProvider = function HttpProvider(host, options) {
options = options || {};
var keepAlive =
(options.keepAlive === true || options.keepAlive !== false) ?
true :
false;
this.host = host || 'http://localhost:8545';
this.timeout = timeout || 0;
if (this.host.substring(0,5) === "https") {
this.httpsAgent = new https.Agent({ keepAlive: keepAlive });
}else{
this.httpAgent = new http.Agent({ keepAlive: keepAlive });
}
this.timeout = options.timeout || 0;
this.headers = options.headers;
this.connected = false;
};
HttpProvider.prototype._prepareRequest = function(){
var request = new XHR2();
request.nodejsSet({
httpsAgent:this.httpsAgent,
httpAgent:this.httpAgent
});
request.open('POST', this.host, true);
request.setRequestHeader('Content-Type','application/json');
request.timeout = this.timeout && this.timeout !== 1 ? this.timeout : 0;
request.withCredentials = true;
if(this.headers) {
this.headers.forEach(function(header) {
request.setRequestHeader(header.name, header.value);
});
}
return request;
};
/**

@@ -49,7 +84,4 @@ * Should be used to make async request

var _this = this;
var request = new XHR2();
var request = this._prepareRequest();
request.open('POST', this.host, true);
request.setRequestHeader('Content-Type','application/json');
request.onreadystatechange = function() {

@@ -84,3 +116,7 @@ if (request.readyState === 4 && request.timeout !== 1) {

HttpProvider.prototype.disconnect = function () {
//NO OP
};
module.exports = HttpProvider;
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