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

needle

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

needle - npm Package Compare versions

Comparing version 0.5.4 to 0.5.5

60

lib/needle.js

@@ -24,8 +24,6 @@ //////////////////////////////////////////

exports.version = version;
try { var unzip = require('zlib').unzip } catch(e) { /* unzip not supported */ }
var default_user_agent = 'Needle/' + version;
default_user_agent += ' (Node.js ' + process.version + '; ' + process.platform + ' ' + process.arch + ')';
var user_agent = 'Needle/' + version;
user_agent += ' (Node.js ' + process.version + '; ' + process.platform + ' ' + process.arch + ')';

@@ -65,2 +63,18 @@ var node_tls_opts = 'agent pfx key passphrase cert ca ciphers rejectUnauthorized secureProtocol';

//////////////////////////////////////////
// defaults
//////////////////////////////////////////
var defaults = {
accept : '*/*',
connection : 'close',
user_agent : user_agent,
follow : 0,
decode_response : true,
parse_response : true,
timeout : 10000,
encoding : 'utf8',
boundary : '--------------------NODENEEDLEHTTPCLIENT'
}
//////////////////////////////////////////
// the main act

@@ -71,5 +85,2 @@ //////////////////////////////////////////

default_boundary: '--------------------NODENEEDLEHTTPCLIENT',
default_user_agent: default_user_agent,
request: function(uri, method, data, options, callback){

@@ -88,7 +99,7 @@

output : options.output,
encoding : options.encoding || (options.multipart ? 'binary' : 'utf8'),
decode_response : options.decode === false ? false : true,
parse_response : options.parse === false ? false : true,
follow : options.follow === true ? 10 : typeof options.follow == 'number' ? options.follow : 0,
timeout : (typeof options.timeout == 'number') ? options.timeout : 10000
encoding : options.encoding || (options.multipart ? 'binary' : defaults.encoding),
decode_response : options.decode === false ? false : defaults.decode_response,
parse_response : options.parse === false ? false : defaults.parse_response,
follow : options.follow === true ? 10 : typeof options.follow == 'number' ? options.follow : defaults.follow,
timeout : (typeof options.timeout == 'number') ? options.timeout : defaults.timeout
}

@@ -98,3 +109,3 @@

node_tls_opts.split(' ').forEach(function(key){
if (typeof options[key] != 'undefined'){
if (typeof options[key] != 'undefined') {
config.base_opts[key] = options[key];

@@ -107,5 +118,5 @@ if (typeof options.agent == 'undefined')

config.headers = {
'Accept' : options.accept || '*/*',
'Connection' : options.connection || 'close',
'User-Agent' : options.user_agent || this.default_user_agent
'Accept' : options.accept || defaults.accept,
'Connection' : options.connection || defaults.connection,
'User-Agent' : options.user_agent || defaults.user_agent
}

@@ -130,5 +141,4 @@

if (options.multipart) {
var boundary = options.boundary || this.default_boundary;
var boundary = options.boundary || defaults.boundary;
return multipart.build(data, boundary, function(err, body){
if (err) throw(err);

@@ -330,2 +340,12 @@ config.headers['Content-Type'] = 'multipart/form-data; boundary=' + boundary;

exports.version = version;
exports.defaults = function(obj) {
for (var key in obj) {
if (defaults[key] && typeof obj[key] != 'undefined')
defaults[key] = obj[key];
}
return defaults;
}
exports.head = function(uri, options, callback){

@@ -349,2 +369,4 @@ return Needle.request(uri, 'HEAD', null, options, callback);

return Needle.request(uri, 'DELETE', data, options, callback);
}
}
exports.request = Needle.request;
{
"name": "needle"
, "version": "0.5.4"
, "version": "0.5.5"
, "description": "Tiny yet feature-packed HTTP client. With multipart, charset decoding and proxy support."

@@ -5,0 +5,0 @@ , "keywords": ["http", "https", "simple", "request", "client", "multipart", "upload", "proxy", "deflate", "timeout", "charset", "iconv"]

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