You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

needle

Package Overview
Dependencies
Maintainers
1
Versions
115
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
3.4.1
to
3.5.0
+6
-5
lib/multipart.js

@@ -42,6 +42,5 @@ var readFile = require('fs').readFile,

function append(data, filename) {
function append(data, filename, force_binary) {
if (data) {
var binary = part.content_type.indexOf('text') == -1;
var binary = force_binary || part.content_type.indexOf('text') == -1;
return_part += '; filename="' + encodeURIComponent(filename) + '"\r\n';

@@ -59,10 +58,12 @@ if (binary) return_part += 'Content-Transfer-Encoding: binary\r\n';

var filename = part.filename ? part.filename : part.file ? basename(part.file) : name;
if (part.buffer) return append(part.buffer, filename);
if (part.buffer) return append(part.buffer, filename, true);
readFile(part.file, function(err, data) {
if (err) return callback(err);
append(data, filename);
append(data, filename, true);
});
} else {
if (!part.value)
throw new Error('value missing for multipart!')

@@ -69,0 +70,0 @@ if (typeof part.value == 'object')

@@ -863,3 +863,3 @@ //////////////////////////////////////////

module.exports[method] = function(uri, options, callback) {
return new Needle(method, uri, null, options, callback).start();
return new Needle(method, uri, options.query, options, callback).start();
}

@@ -866,0 +866,0 @@ })

{
"name": "needle",
"version": "3.4.1",
"version": "3.5.0",
"description": "The leanest and most handsome HTTP client in the Nodelands.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -149,3 +149,3 @@ var needle = require('..'),

get({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) {
post({ foo: 'bar', test: '测试' }, { multipart: true }, function(err, resp) {
spy.called.should.be.true;

@@ -159,3 +159,30 @@

describe('when buffer', function() {
it('includes Content-Transfer-Encoding: binary header', function(done) {
spystub_request();
post({ foo: { buffer: Buffer.from('test content'), content_type: 'application/octet-stream' } }, { multipart: true }, function(err, resp) {
spy.called.should.be.true;
resp.body.body.should.containEql('Content-Transfer-Encoding: binary');
done();
})
})
})
describe('when file', function() {
it('includes Content-Transfer-Encoding: binary header', function(done) {
spystub_request();
post({ foo: { file: __dirname + '/keys/ssl.key', content_type: 'application/octet-stream' } }, { multipart: true }, function(err, resp) {
spy.called.should.be.true;
resp.body.body.should.containEql('Content-Transfer-Encoding: binary');
done();
})
})
})
})

@@ -162,0 +189,0 @@