superagent
Advanced tools
+0
-3
| { | ||
| "name": "superagent", | ||
| "main": "lib/client.js", | ||
| "dependencies": { | ||
| "form-data": "form-data-superagent#^1.0.0" | ||
| } | ||
| } |
+2
-2
| { | ||
| "name": "superagent", | ||
| "repo": "visionmedia/superagent", | ||
| "description": "awesome http requests", | ||
| "version": "1.2.0", | ||
| "version": "1.8.2", | ||
| "description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
| "keywords": [ | ||
@@ -7,0 +7,0 @@ "http", |
+7
-0
@@ -0,1 +1,8 @@ | ||
| # 1.8.2 (2016-03-20) | ||
| * Fixed handling of HTTP status 204 with content-encoding: gzip (Andrew Shelton) | ||
| * Handling of FormData error events (scriptype) | ||
| * Fixed parsing of `vnd+json` MIME types (Kornel Lesiński) | ||
| * Aliased browser implementation of `.parse()` as `.serialize()` for forward compatibility | ||
| # 1.8.1 (2016-03-14) | ||
@@ -2,0 +9,0 @@ |
+27
-2
@@ -393,2 +393,5 @@ /** | ||
| var parse = request.parse[this.type]; | ||
| if (!parse && isJSON(this.type)) { | ||
| parse = request.parse['application/json']; | ||
| } | ||
| return parse && str && (str.length || str instanceof Object) | ||
@@ -695,7 +698,13 @@ ? parse(str) | ||
| Request.prototype.attach = function(field, file, filename){ | ||
| if (!this._formData) this._formData = new root.FormData(); | ||
| this._formData.append(field, file, filename || file.name); | ||
| this._getFormData().append(field, file, filename || file.name); | ||
| return this; | ||
| }; | ||
| Request.prototype._getFormData = function(){ | ||
| if (!this._formData) { | ||
| this._formData = new root.FormData(); | ||
| } | ||
| return this._formData; | ||
| }; | ||
| /** | ||
@@ -770,2 +779,18 @@ * Send `data` as the request body, defaulting the `.type()` to "json" when | ||
| /** | ||
| * @deprecated | ||
| */ | ||
| Response.prototype.parse = function serialize(fn){ | ||
| if (root.console) { | ||
| console.warn("Client-side parse() method has been renamed to serialize(). This method is not compatible with superagent v2.0"); | ||
| } | ||
| this.serialize(fn); | ||
| return this; | ||
| }; | ||
| Response.prototype.serialize = function serialize(fn){ | ||
| this._parser = fn; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Invoke the callback with `err` and `res` | ||
@@ -772,0 +797,0 @@ * and handle arity check. |
+35
-5
@@ -180,3 +180,2 @@ | ||
| Request.prototype.attach = function(field, file, filename){ | ||
| if (!this._formData) this._formData = new FormData(); | ||
| if ('string' == typeof file) { | ||
@@ -186,9 +185,20 @@ if (!filename) filename = file; | ||
| file = fs.createReadStream(file); | ||
| } else if(!filename && file.path) { | ||
| } else if (!filename && file.path) { | ||
| filename = file.path; | ||
| } | ||
| this._formData.append(field, file, { filename: filename }); | ||
| this._getFormData().append(field, file, { filename: filename }); | ||
| return this; | ||
| }; | ||
| Request.prototype._getFormData = function() { | ||
| if (!this._formData) { | ||
| this._formData = new FormData(); | ||
| this._formData.on('error', function(err) { | ||
| this.emit('error', err); | ||
| this.abort(); | ||
| }.bind(this)); | ||
| } | ||
| return this._formData; | ||
| }; | ||
| /** | ||
@@ -434,3 +444,3 @@ * Set the max redirects to `n`. | ||
| if (/^(deflate|gzip)$/.test(res.headers['content-encoding'])) { | ||
| if (self._shouldUnzip(res)) { | ||
| res.pipe(zlib.createUnzip()).pipe(stream, options); | ||
@@ -817,6 +827,7 @@ } else { | ||
| // zlib support | ||
| if (/^(deflate|gzip)$/.test(res.headers['content-encoding'])) { | ||
| if (self._shouldUnzip(res)) { | ||
| utils.unzip(req, res); | ||
| } | ||
| // don't buffer multipart | ||
@@ -970,2 +981,21 @@ if (multipart) buffer = false; | ||
| /** | ||
| * Check whether response has a non-0-sized gzip-encoded body | ||
| */ | ||
| Request.prototype._shouldUnzip = function(res){ | ||
| if (res.statusCode === 204 || res.statusCode === 304) { | ||
| // These aren't supposed to have any body | ||
| return false; | ||
| } | ||
| // header content is a string, and distinction between 0 and no information is crucial | ||
| if ('0' === res.headers['content-length']) { | ||
| // We know that the body is empty (unfortunately, this check does not cover chunked encoding) | ||
| return false; | ||
| } | ||
| // console.log(res); | ||
| return /^\s*(?:deflate|gzip)\s*$/.test(res.headers['content-encoding']); | ||
| }; | ||
| /** | ||
| * To json. | ||
@@ -972,0 +1002,0 @@ * |
+1
-2
@@ -128,4 +128,3 @@ | ||
| // add `this` Stream's readable side as a stream for this Part | ||
| if (!this._req._formData) this._req._formData = new FormData(); | ||
| this._req._formData.append(this._name, this, { | ||
| this._req._getFormData().append(this._name, this, { | ||
| contentType: this._type, | ||
@@ -132,0 +131,0 @@ filename: this._filename |
@@ -164,8 +164,4 @@ /** | ||
| exports.field = function(name, val) { | ||
| if (!this._formData) { | ||
| var FormData = require('form-data'); // browserify compatible. May throw if FormData is not supported natively. | ||
| this._formData = new FormData(); | ||
| } | ||
| this._formData.append(name, val); | ||
| this._getFormData().append(name, val); | ||
| return this; | ||
| }; |
+3
-1
| { | ||
| "name": "superagent", | ||
| "version": "1.8.1", | ||
| "version": "1.8.2", | ||
| "description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -18,2 +18,4 @@ "scripts": { | ||
| "contributors": [ | ||
| "Kornel Lesiński <kornel@geekhood.net>", | ||
| "Peter Lyons <pete@peterlyons.com>", | ||
| "Hunter Loftis <hunter@hunterloftis.com>" | ||
@@ -20,0 +22,0 @@ ], |
+31
-12
@@ -180,11 +180,7 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.superagent=e()}}(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){ | ||
| exports.field = function(name, val) { | ||
| if (!this._formData) { | ||
| var FormData = require('form-data'); // browserify compatible. May throw if FormData is not supported natively. | ||
| this._formData = new FormData(); | ||
| } | ||
| this._formData.append(name, val); | ||
| this._getFormData().append(name, val); | ||
| return this; | ||
| }; | ||
| },{"./is-object":1,"form-data":5}],3:[function(require,module,exports){ | ||
| },{"./is-object":1}],3:[function(require,module,exports){ | ||
| // The node and browser modules expose versions of this with the | ||
@@ -387,4 +383,2 @@ // appropriate constructor function bound as first argument | ||
| },{}],5:[function(require,module,exports){ | ||
| module.exports = FormData; | ||
| },{}],6:[function(require,module,exports){ | ||
@@ -414,3 +408,3 @@ /** | ||
| }; | ||
| },{}],7:[function(require,module,exports){ | ||
| },{}],6:[function(require,module,exports){ | ||
| /** | ||
@@ -808,2 +802,5 @@ * Module dependencies. | ||
| var parse = request.parse[this.type]; | ||
| if (!parse && isJSON(this.type)) { | ||
| parse = request.parse['application/json']; | ||
| } | ||
| return parse && str && (str.length || str instanceof Object) | ||
@@ -1110,7 +1107,13 @@ ? parse(str) | ||
| Request.prototype.attach = function(field, file, filename){ | ||
| if (!this._formData) this._formData = new root.FormData(); | ||
| this._formData.append(field, file, filename || file.name); | ||
| this._getFormData().append(field, file, filename || file.name); | ||
| return this; | ||
| }; | ||
| Request.prototype._getFormData = function(){ | ||
| if (!this._formData) { | ||
| this._formData = new root.FormData(); | ||
| } | ||
| return this._formData; | ||
| }; | ||
| /** | ||
@@ -1185,2 +1188,18 @@ * Send `data` as the request body, defaulting the `.type()` to "json" when | ||
| /** | ||
| * @deprecated | ||
| */ | ||
| Response.prototype.parse = function serialize(fn){ | ||
| if (root.console) { | ||
| console.warn("Client-side parse() method has been renamed to serialize(). This method is not compatible with superagent v2.0"); | ||
| } | ||
| this.serialize(fn); | ||
| return this; | ||
| }; | ||
| Response.prototype.serialize = function serialize(fn){ | ||
| this._parser = fn; | ||
| return this; | ||
| }; | ||
| /** | ||
| * Invoke the callback with `err` and `res` | ||
@@ -1472,3 +1491,3 @@ * and handle arity check. | ||
| },{"./is-object":1,"./request":3,"./request-base":2,"emitter":4,"reduce":6}]},{},[7])(7) | ||
| },{"./is-object":1,"./request":3,"./request-base":2,"emitter":4,"reduce":5}]},{},[6])(6) | ||
| }); |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance 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
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance 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
319657
0.54%4263
1.31%