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

superagent

Package Overview
Dependencies
Maintainers
10
Versions
174
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 3.0.0-alpha.1 to 3.0.0-alpha.2

superagent.js.gz

6

docs/index.md

@@ -48,3 +48,3 @@

});
The __node__ client supports making requests to [Unix Domain Sockets](http://en.wikipedia.org/wiki/Unix_domain_socket):

@@ -425,4 +425,4 @@

.end(function(err, res){
assert(200 == res.status);
assert('tobi' == res.text);
assert.equal(200, res.status);
assert.equal('tobi', res.text);
next();

@@ -429,0 +429,0 @@ })

# 3.0.0
You can test it with `npm install superagent@next`
* Dropped support for Node 0.x. Please upgrade to at least Node 4.
* Dropped support for componentjs (Damien Caselli)
* Removed deprecated `.part()`/`superagent.Part` APIs.
* Removed unreliable `.body` property on internal response object used by unbuffered parsers.
Note: the normal `response.body` is unaffected.
* Multiple `.send()` calls mixing `Buffer`/`Blob` and JSON data are not possible and will now throw instead of messing up the data.
* Improved `.send()` data object type check (Fernando Mendes)
* Added common prototype for Node and browser versions (Andreas Helmberger)
* Added `http+unix:` schema to support Unix sockets (Yuki KAN)
* Added full `attach` options parameter in the Node version (Lapo Luchini)
* Added `pfx` TLS option with new `pfx()` method. (Reid Burke)
* Internally changed `.on` to `.once` to prevent possible memory leaks (Matt Blair)

@@ -9,0 +17,0 @@ * Made all errors reported as an event (Kornel Lesiński)

@@ -715,2 +715,13 @@ /**

// This only warns, because the request is still likely to work
Request.prototype.buffer = Request.prototype.ca = Request.prototype.agent = function(){
console.warn("This is not supported in browser version of superagent");
return this;
};
// This throws, because it can't send/receive data as expected
Request.prototype.pipe = Request.prototype.write = function(){
throw Error("Streaming is not supported in browser version of superagent");
};
/**

@@ -745,2 +756,15 @@ * Invoke callback with timeout error.

/**
* Check if `obj` is a host object,
* we don't want to serialize these :)
*
* @param {Object} obj
* @return {Boolean}
* @api private
*/
Request.prototype._isHost = function _isHost(obj) {
// Native objects stringify to [object File], [object Blob], [object FormData], etc.
return obj && 'object' === typeof obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]';
}
/**
* Initiate request, invoking callback `fn(res)`

@@ -747,0 +771,0 @@ * with an instanceof `Response`.

@@ -29,2 +29,3 @@

this._key = options.key;
this._pfx = options.pfx;
this._cert = options.cert;

@@ -79,2 +80,3 @@ }

req.key(this._key);
req.pfx(this._pfx);
req.cert(this._cert);

@@ -81,0 +83,0 @@

@@ -17,3 +17,2 @@

var extend = require('extend');
var Part = require('./part');
var mime = require('mime');

@@ -42,8 +41,2 @@ var https = require('https');

/**
* Expose `Part`.
*/
exports.Part = Part;
/**
* Noop.

@@ -207,15 +200,2 @@ */

/**
* Return a new `Part` for this request.
*
* @return {Part}
* @api public
* @deprecated pass a readable stream in to `Request#attach()` instead
*/
Request.prototype.part = util.deprecate(function(){
return new Part(this);
}, '`Request#part()` is deprecated. ' +
'Pass a readable stream in to `Request#attach()` instead.');
/**
* Gets/sets the `Agent` to use for this HTTP request. The default (if this

@@ -511,2 +491,15 @@ * function is not called) is to opt out of connection pooling (`agent: false`).

/**
* Set the key, certificate, and CA certs of the client in PFX or PKCS12 format.
*
* @param {Buffer | String} cert
* @return {Request} for chaining
* @api public
*/
Request.prototype.pfx = function(cert){
this._pfx = cert;
return this;
};
/**
* Set the client certificate option for https request.

@@ -560,2 +553,3 @@ *

options.key = this._key;
options.pfx = this._pfx;
options.cert = this._cert;

@@ -620,3 +614,3 @@ options.agent = this._agent;

this.clearTimeout();
if (this.called) return console.warn('double callback!');
if (this.called) return console.warn('superagent: double callback bug');
this.called = true;

@@ -664,2 +658,13 @@

/**
* Check if `obj` is a host object,
*
* @param {Object} obj
* @return {Boolean}
* @api private
*/
Request.prototype._isHost = function _isHost(obj) {
return Buffer.isBuffer(obj) || obj instanceof Stream || obj instanceof FormData;
}
/**
* Initiate request, invoking callback `fn(err, res)`

@@ -806,4 +811,2 @@ * with an instanceof `Response`.

res.body = obj; // Deprecated. For backwards compat only. It's not the response object user sees.
if (parserHandlesEnd) {

@@ -810,0 +813,0 @@ self.emit('end');

@@ -310,26 +310,3 @@ /**

/**
* Check if `obj` is a host object,
* we don't want to serialize these :)
*
* TODO: future proof, move to compoent land
*
* @param {Object} obj
* @return {Boolean}
* @api private
*/
RequestBase.prototype._isHost = function _isHost(obj) {
var str = {}.toString.call(obj);
switch (str) {
case '[object File]':
case '[object Blob]':
case '[object FormData]':
return true;
default:
return false;
}
}
/**

@@ -376,7 +353,17 @@ * Send `data` as the request body, defaulting the `.type()` to "json" when

RequestBase.prototype.send = function(data){
var obj = isObject(data);
var isObj = isObject(data);
var type = this._header['content-type'];
if (isObj && !this._data) {
if (Array.isArray(data)) {
this._data = [];
} else if (!this._isHost(data)) {
this._data = {};
}
} else if (data && this._data && this._isHost(this._data)) {
throw Error("Can't merge these send calls");
}
// merge
if (obj && isObject(this._data)) {
if (isObj && isObject(this._data)) {
for (var key in data) {

@@ -400,3 +387,3 @@ this._data[key] = data[key];

if (!obj || this._isHost(data)) return this;
if (!isObj || this._isHost(data)) return this;

@@ -403,0 +390,0 @@ // default to json

{
"name": "superagent",
"version": "3.0.0-alpha.1",
"version": "3.0.0-alpha.2",
"description": "elegant & feature rich browser / node HTTP with a fluent API",

@@ -41,3 +41,2 @@ "scripts": {

"basic-auth-connect": "^1.0.0",
"better-assert": "^1.0.1",
"body-parser": "^1.15.0",

@@ -44,0 +43,0 @@ "browserify": "^13.0.0",

@@ -326,26 +326,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

/**
* Check if `obj` is a host object,
* we don't want to serialize these :)
*
* TODO: future proof, move to compoent land
*
* @param {Object} obj
* @return {Boolean}
* @api private
*/
RequestBase.prototype._isHost = function _isHost(obj) {
var str = {}.toString.call(obj);
switch (str) {
case '[object File]':
case '[object Blob]':
case '[object FormData]':
return true;
default:
return false;
}
}
/**

@@ -392,7 +369,17 @@ * Send `data` as the request body, defaulting the `.type()` to "json" when

RequestBase.prototype.send = function(data){
var obj = isObject(data);
var isObj = isObject(data);
var type = this._header['content-type'];
if (isObj && !this._data) {
if (Array.isArray(data)) {
this._data = [];
} else if (!this._isHost(data)) {
this._data = {};
}
} else if (data && this._data && this._isHost(this._data)) {
throw Error("Can't merge these send calls");
}
// merge
if (obj && isObject(this._data)) {
if (isObj && isObject(this._data)) {
for (var key in data) {

@@ -416,3 +403,3 @@ this._data[key] = data[key];

if (!obj || this._isHost(data)) return this;
if (!isObj || this._isHost(data)) return this;

@@ -1338,2 +1325,13 @@ // default to json

// This only warns, because the request is still likely to work
Request.prototype.buffer = Request.prototype.ca = Request.prototype.agent = function(){
console.warn("This is not supported in browser version of superagent");
return this;
};
// This throws, because it can't send/receive data as expected
Request.prototype.pipe = Request.prototype.write = function(){
throw Error("Streaming is not supported in browser version of superagent");
};
/**

@@ -1368,2 +1366,15 @@ * Invoke callback with timeout error.

/**
* Check if `obj` is a host object,
* we don't want to serialize these :)
*
* @param {Object} obj
* @return {Boolean}
* @api private
*/
Request.prototype._isHost = function _isHost(obj) {
// Native objects stringify to [object File], [object Blob], [object FormData], etc.
return obj && 'object' === typeof obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]';
}
/**
* Initiate request, invoking callback `fn(res)`

@@ -1370,0 +1381,0 @@ * with an instanceof `Response`.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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