Socket
Socket
Sign inDemoInstall

superagent

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superagent - npm Package Compare versions

Comparing version 0.9.4 to 0.9.5

lib/node/parsers/text.js

8

History.md
0.9.5 / 2012-10-01
==================
* add field name to .attach()
* add text "parser"
* refactor isObject()
* remove wtf isFunction() helper
0.9.4 / 2012-09-20

@@ -3,0 +11,0 @@ ==================

29

lib/node/index.js

@@ -148,2 +148,3 @@

*
* @param {String} field
* @param {String} file

@@ -155,7 +156,8 @@ * @param {String} filename

Request.prototype.attach = function(file, filename){
Request.prototype.attach = function(field, file, filename){
this.attachments.push({
name: file
, part: new Part(this)
, filename: filename
field: field,
path: file,
part: new Part(this),
filename: filename || file
});

@@ -658,8 +660,6 @@ return this;

if (buffer) {
res.text = '';
res.setEncoding('utf8');
res.on('data', function(chunk){ res.text += chunk; });
var parse = 'text' == type
? exports.parse.text
: exports.parse[utils.type(res.headers['content-type'] || '')];
// parser
var parse = exports.parse[utils.type(res.headers['content-type'] || '')];
if (parse) {

@@ -730,12 +730,5 @@ parse(res, function(err, obj){

// custom filename
if (file.filename) {
file.part.type(file.name);
file.part.set('Content-Disposition', 'attachment; filename="' + file.filename + '"');
} else {
file.part.filename(file.name);
}
file.part.attachment(file.field, file.filename);
var stream = fs.createReadStream(file.path);
var stream = fs.createReadStream(file.name);
// TODO: pipe

@@ -742,0 +735,0 @@ // TODO: handle errors

exports['application/x-www-form-urlencoded'] = require('./urlencoded');
exports['application/json'] = require('./json');
exports.text = require('./text');
module.exports = function(res, fn){
var buf = '';
res.text = '';
res.setEncoding('utf8');
res.on('data', function(chunk){ buf += chunk; });
res.on('data', function(chunk){ res.text += chunk; });
res.on('end', function(){
try {
fn(null, JSON.parse(buf));
fn(null, JSON.parse(res.text));
} catch (err) {

@@ -10,0 +10,0 @@ fn(err);

@@ -9,8 +9,8 @@

module.exports = function(res, fn){
var buf = '';
res.text = '';
res.setEncoding('ascii');
res.on('data', function(chunk){ buf += chunk; });
res.on('data', function(chunk){ res.text += chunk; });
res.on('end', function(){
try {
fn(null, qs.parse(buf));
fn(null, qs.parse(res.text));
} catch (err) {

@@ -17,0 +17,0 @@ fn(err);

@@ -114,4 +114,6 @@

/**
* Set _Content-Disposition_ header field to _attachment_ with `filename`.
* Set _Content-Disposition_ header field to _attachment_ with `filename`
* and field `name`.
*
* @param {String} name
* @param {String} filename

@@ -122,5 +124,5 @@ * @return {Part}

Part.prototype.filename = function(filename){
Part.prototype.attachment = function(name, filename){
this.type(filename);
this.set('Content-Disposition', 'attachment; filename="' + basename(filename) + '"');
this.set('Content-Disposition', 'attachment; name="' + name + '"; filename="' + basename(filename) + '"');
return this;

@@ -127,0 +129,0 @@ };

@@ -49,14 +49,2 @@

/**
* Check if `obj` is a function.
*
* @param {Mixed} obj
* @return {Boolean}
* @api private
*/
function isFunction(obj) {
return 'function' == typeof obj;
}
/**

@@ -71,3 +59,3 @@ * Check if `obj` is an object.

function isObject(obj) {
return null != obj && 'object' == typeof obj;
return obj === Object(obj);
}

@@ -673,3 +661,3 @@

var req = request('GET', url);
if (isFunction(data)) fn = data, data = null;
if ('function' == typeof data) fn = data, data = null;
if (data) req.query(data);

@@ -692,3 +680,3 @@ if (fn) req.end(fn);

var req = request('HEAD', url);
if (isFunction(data)) fn = data, data = null;
if ('function' == typeof data) fn = data, data = null;
if (data) req.send(data);

@@ -695,0 +683,0 @@ if (fn) req.end(fn);

{
"name": "superagent",
"version": "0.9.4",
"version": "0.9.5",
"description": "elegant & feature rich browser / node HTTP with a fluent API",

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

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