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

dry-underscore

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dry-underscore - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

lib/zandbox/ssl/test.cert

31

lib/http.client.js

@@ -72,34 +72,3 @@ function library(){

request_manager.prototype.connect_writer = function(call, callback){
callback = callback || _.noop;
var req = http.request(call, function(res) {
var body = "";
res.setEncoding('utf8');
res.on('data', function (chunk) { body += chunk; });
res.on('end', function(){
var client_response = {
body: body,
status: res.statusCode
};
callback(null, client_response, body);
});
});
var dead = false;
req.on('error', function(err){
dead = true;
return callback(err);
});
return({
end: function(d){ if(!dead){ req.write(d); } req.end(); },
write: function(d){ if(!dead){ req.write(d); } }
});
};
request_manager.prototype.connect_writer = function(call, callback){
var xhr = getXHR();

@@ -106,0 +75,0 @@

26

lib/http.node.js
var http = require('http');
var https = require('https');

@@ -12,11 +12,15 @@ function library(_){

var host = _.url.parse(url);
var secure = (host.protocol && host.protocol === "https:") || host.port === 443;
var options = {
secure: secure,
host: host.hostname,
port: host.port || 80,
port: host.port || (secure ? 443 : 80),
path: host.pathname + (host.search ? host.search : ""),
method: method,
headers : {}
headers : {},
};
if(this.unsafe){ options.rejectUnauthorized = false; }
return(options);

@@ -64,3 +68,14 @@ };

request_manager.prototype.make_request = function(call, res_handler){
var req = null;
if(call.secure){
req = https.request(call, res_handler);
}else{
req = http.request(call, res_handler);
}
return(req);
};
request_manager.prototype.connect_writer = function(call, callback){

@@ -70,5 +85,4 @@

var req = http.request(call, function(res) {
var req = this.make_request(call, function(res) {
var body = "";
res.setEncoding('utf8');

@@ -75,0 +89,0 @@ res.on('data', function (chunk) { body += chunk; });

@@ -5,2 +5,8 @@ "use strict";

var root = _.path.fun(__dirname);
var fs = require('fs');
var http = require('http');
var https = require('https');
var express = require('express');

@@ -13,8 +19,6 @@

var server = null;
var http_server = null;
var https_server = null;
function start_server(callback){
var app = express();
function add_handlers(app, name){
app.get('/get', function(req, res){

@@ -40,10 +44,31 @@

});
}
server = app.listen(9999);
function start_server(callback){
callback();
var http_app = express();
var https_app = express();
var ssl_options = {
key : fs.readFileSync(root("zandbox/ssl/test.key"), 'utf8'),
cert : fs.readFileSync(root("zandbox/ssl/test.cert"), 'utf8'),
ca: []
}
add_handlers(http_app, "http");
add_handlers(https_app, "https");
http_server = http.createServer(http_app);
https_server = https.createServer(ssl_options, https_app);
https_server.listen(9998, function(){
http_server.listen(9999, function(){
callback();
});
});
};
function stop_server(callback){
server.close();
http_server.close();
https_server.close();
callback();

@@ -66,2 +91,15 @@ };

test("get https", function(done){
_.http.unsafe = true;
_.http.get("https://localhost:9998/get", function(err, res, body){
eq(err, null);
ok(res);
eq(res.body, "0123");
eq(res.status, 200);
eq(body, "0123");
done();
});
});
test("post", function(done){

@@ -75,2 +113,10 @@ _.http.post("http://localhost:9999/post", "hello", function(err, res, body){

test("post https", function(done){
_.http.post("https://localhost:9998/post", "hello", function(err, res, body){
eq(res.status, 202);
eq(body, "good");
done();
});
});
test("post writer", function(done){

@@ -77,0 +123,0 @@ var r = _.http.post("http://localhost:9999/post", function(err, res, body){

{
"name": "dry-underscore",
"version": "0.10.0",
"version": "0.10.1",
"dependencies": {

@@ -5,0 +5,0 @@ "formidable": {

{
"name": "dry-underscore",
"version": "0.10.0",
"version": "0.10.1",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "description": "The DRY Undescore Library",

Sorry, the diff of this file is too big to display

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