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

node-ral

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ral - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0

test/proxy.js

4

lib/ext/converter/jsonConverter.js

@@ -39,2 +39,6 @@ /**

buffer = iconv.encode(JSON.stringify(data), config.encoding);
if (!config.skipContentLength) {
config.headers = config.headers || {};
config.headers['Content-Length'] = buffer.length;
}
}

@@ -41,0 +45,0 @@ catch (ex) {

@@ -26,2 +26,4 @@ /**

RawConverter.prototype.pack = function (config, data) {
config.headers = config.headers || {};
config.headers['Content-Length'] = data.length;
return data;

@@ -28,0 +30,0 @@ };

@@ -40,2 +40,6 @@ /**

buffer = iconv.encode(data.toString(), config.encoding);
if (!config.skipContentLength) {
config.headers = config.headers || {};
config.headers['Content-Length'] = buffer.length;
}
}

@@ -42,0 +46,0 @@ catch (e) {

16

lib/ext/protocol/httpProtocolBase.js

@@ -20,3 +20,5 @@ /**

var urlParse = require('url').parse;
var HttpsProxyAgent = require('https-proxy-agent');
function HttpProtocolBase() {

@@ -157,6 +159,12 @@ Protocol.call(this);

}
opt.path = url.resolve(uri, path);
var proxyUri = url.parse(proxy);
opt.host = proxyUri.hostname;
opt.port = proxyUri.port ? proxyUri.port : (proxyUri.protocol === 'http:' ? 80 : 433);
if (opt.protocol === 'https:') {
var agent = new HttpsProxyAgent(proxy);
opt.agent = agent;
}
else {
opt.path = url.resolve(uri, path);
var proxyUri = url.parse(proxy);
opt.host = proxyUri.hostname;
opt.port = proxyUri.port ? proxyUri.port : (proxyUri.protocol === 'http:' ? 80 : 433);
}
}

@@ -163,0 +171,0 @@

{
"name": "node-ral",
"version": "0.6.2",
"version": "0.7.0",
"description": "a rpc client for node",

@@ -30,2 +30,3 @@ "main": "index.js",

"form-data": "0.1.4",
"https-proxy-agent": "1.0.0",
"iconv-lite": "0.4.13",

@@ -32,0 +33,0 @@ "performance-now": "0.2.0",

@@ -88,5 +88,7 @@ /**

};
var pack = jsonConverter.pack(mockUTF8Context, data);
var unpack = jsonConverter.unpack(mockUTF8Context, pack);
var options = _.clone(mockUTF8Context);
var pack = jsonConverter.pack(options, data);
var unpack = jsonConverter.unpack(_.clone(mockUTF8Context), pack);
data.should.be.eql(unpack);
options.headers['Content-Length'].should.be.eql(20);
});

@@ -98,5 +100,5 @@

var data = '张三李四';
var pack = converter.pack(mockUTF8Context, data);
var pack = converter.pack(_.clone(mockUTF8Context), data);
(function () {
jsonConverter.unpack(mockUTF8Context, pack);
jsonConverter.unpack(_.clone(mockUTF8Context), pack);
}).should.throwError();

@@ -111,7 +113,23 @@ });

};
var pack = jsonConverter.pack(mockGBKContext, data);
var unpack = jsonConverter.unpack(mockGBKContext, pack);
var options = _.clone(mockGBKContext);
var pack = jsonConverter.pack(options, data);
var unpack = jsonConverter.unpack(_.clone(mockGBKContext), pack);
data.should.be.eql(unpack);
options.headers['Content-Length'].should.be.eql(18);
});
it('pack and unpack could skip header', function () {
var jsonConverter = new JsonConverter();
var data = {
a: 1,
b: '张三'
};
var options = _.clone(mockGBKContext);
options.skipContentLength = true;
var pack = jsonConverter.pack(options, data);
var unpack = jsonConverter.unpack(_.clone(mockGBKContext), pack);
data.should.be.eql(unpack);
(options.headers === undefined).should.be.true;
});
it('pack should fail if encoding is illegal', function () {

@@ -121,3 +139,3 @@ var converter = new JsonConverter();

(function () {
converter.pack(mockBlahContext, data);
converter.pack(_.clone(mockBlahContext), data);
}).should.throwError();

@@ -130,3 +148,3 @@ });

(function () {
jsonConverter.pack(mockUTF8Context, data);
jsonConverter.pack(_.clone(mockUTF8Context), data);
}).should.not.throwError();

@@ -150,5 +168,7 @@ });

var data = '张三李四';
var pack = converter.pack(mockUTF8Context, data);
var unpack = converter.unpack(mockUTF8Context, pack);
var options = _.clone(mockUTF8Context);
var pack = converter.pack(options, data);
var unpack = converter.unpack(_.clone(mockUTF8Context), pack);
data.should.be.eql(unpack);
options.headers['Content-Length'].should.be.eql(12);
});

@@ -159,7 +179,20 @@

var data = '张三李四';
var pack = converter.pack(mockGBKContext, data);
var unpack = converter.unpack(mockGBKContext, pack);
var options = _.clone(mockGBKContext);
var pack = converter.pack(options, data);
var unpack = converter.unpack(_.clone(mockGBKContext), pack);
data.should.be.eql(unpack);
options.headers['Content-Length'].should.be.eql(8);
});
it('pack and unpack could skip header', function () {
var converter = new StringConverter();
var data = '张三李四';
var options = _.clone(mockGBKContext);
options.skipContentLength = true;
var pack = converter.pack(options, data);
var unpack = converter.unpack(_.clone(mockGBKContext), pack);
data.should.be.eql(unpack);
(options.headers === undefined).should.be.true;
});
it('pack should fail if encoding is illegal', function () {

@@ -169,3 +202,3 @@ var converter = new StringConverter();

(function () {
converter.pack(mockBlahContext, data);
converter.pack(_.clone(mockBlahContext), data);
}).should.throwError();

@@ -178,3 +211,3 @@ });

(function () {
converter.pack(mockUTF8Context, data);
converter.pack(_.clone(mockUTF8Context), data);
}).should.not.throwError();

@@ -181,0 +214,0 @@ });

@@ -144,2 +144,3 @@ /**

if (pathname === '/hello' && request.method === 'POST') {
var formIn = new formidable.IncomingForm();

@@ -159,2 +160,3 @@ // var decodeStream = iconv.decodeStream(encoding || 'utf-8');

formIn.parse(request, function (err, fields, files) {
var content = 'hear you';

@@ -161,0 +163,0 @@ response.writeHead(200, {

@@ -692,3 +692,3 @@ /**

}).on('data', function (data) {
data.should.match(/STATUS OK/);
data.should.match(/html/);
done();

@@ -712,3 +712,3 @@ }).on('error', function (err) {

}).on('data', function (data) {
data.should.match(/STATUS OK/);
data.should.match(/html/);
done();

@@ -715,0 +715,0 @@ }).on('error', function (err) {

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