superagent
Advanced tools
Comparing version 0.9.5 to 0.9.6
@@ -7,3 +7,6 @@ { | ||
"keywords": ["http", "ajax", "request", "agent"], | ||
"main": "lib/superagent.js" | ||
} | ||
"scripts": ["index.js", "lib/superagent.js"], | ||
"dependencies": { | ||
"component/emitter": "0.0.6" | ||
} | ||
} |
0.9.6 / 2012-10-17 | ||
================== | ||
* change: use `this` when `window` is undefined | ||
* update to new component spec [juliangruber] | ||
* fix emission of "data" events for compressed responses without encoding. Closes #125 | ||
0.9.5 / 2012-10-01 | ||
@@ -3,0 +10,0 @@ ================== |
11
index.js
@@ -1,4 +0,7 @@ | ||
module.exports = process.env.SUPERAGENT_COV | ||
? require('./lib-cov/node') | ||
: require('./lib/node'); | ||
if (typeof window != 'undefined') { | ||
module.exports = require('./lib/superagent'); | ||
} else if (process.env.SUPERAGENT_COV) { | ||
module.exports = require('./lib-cov/node'); | ||
} else { | ||
module.exports = require('./lib/node'); | ||
} |
@@ -95,7 +95,7 @@ | ||
var unzip = zlib.createUnzip() | ||
, decodedStream = new Stream | ||
, stream = new Stream | ||
, decoder; | ||
// make node responseOnEnd() happy | ||
decodedStream.req = req; | ||
stream.req = req; | ||
@@ -112,8 +112,12 @@ // pipe to unzip | ||
unzip.on('data', function(buf){ | ||
var str = decoder.write(buf); | ||
if (str.length) decodedStream.emit('data', str); | ||
if (decoder) { | ||
var str = decoder.write(buf); | ||
if (str.length) stream.emit('data', str); | ||
} else { | ||
stream.emit('data', buf); | ||
} | ||
}); | ||
unzip.on('end', function(){ | ||
decodedStream.emit('end'); | ||
stream.emit('end'); | ||
}); | ||
@@ -125,3 +129,3 @@ | ||
if ('data' == type || 'end' == type) { | ||
decodedStream.on(type, fn); | ||
stream.on(type, fn); | ||
} else { | ||
@@ -128,0 +132,0 @@ _on.call(res, type, fn); |
@@ -1,2 +0,1 @@ | ||
/*! | ||
@@ -8,2 +7,4 @@ * superagent | ||
var root = typeof window == 'undefined' ? this : window; | ||
;(function(){ | ||
@@ -26,4 +27,4 @@ | ||
function getXHR() { | ||
if (window.XMLHttpRequest | ||
&& ('file:' != window.location.protocol || !window.ActiveXObject)) { | ||
if (root.XMLHttpRequest | ||
&& ('file:' != root.location.protocol || !root.ActiveXObject)) { | ||
return new XMLHttpRequest; | ||
@@ -754,3 +755,3 @@ } else { | ||
if ('undefined' == typeof exports) { | ||
window.request = window.superagent = request; | ||
root.request = root.superagent = request; | ||
} else { | ||
@@ -757,0 +758,0 @@ module.exports = request; |
{ | ||
"name": "superagent", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
16
test.js
@@ -5,6 +5,12 @@ | ||
request | ||
.post('http://127.0.0.1:3000/') | ||
.send('foo=bar') | ||
.end(function(res){ | ||
console.log(res.text); | ||
}) | ||
.get('http://othstatic.propertycdn.com/clean/js/load.v5.6.4.js') | ||
.set('Accept-Encoding', 'gzip') | ||
.end(function(res){ | ||
console.log(res.header['content-encoding']); | ||
res.on('data', function(chunk){ | ||
console.log(chunk.toString()); | ||
}).on('end', function(){ | ||
console.log('end'); | ||
}); | ||
}) | ||
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
119123
29
3826
8