+6
-5
@@ -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') |
+1
-1
@@ -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 @@ }) |
+1
-1
| { | ||
| "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 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 4 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
329849
0.34%6253
0.35%70
-1.41%