superagent
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -1039,2 +1039,18 @@ ;(function(){ | ||
/** | ||
* Enable transmission of cookies with x-domain requests. | ||
* | ||
* Note that for this to work the origin must not be | ||
* using "Access-Control-Allow-Origin" with a wildcard, | ||
* and also must set "Access-Control-Allow-Credentials" | ||
* to "true". | ||
* | ||
* @api public | ||
*/ | ||
Request.prototype.withCredentials = function(){ | ||
this._withCredentials = true; | ||
return this; | ||
}; | ||
/** | ||
* Initiate request, invoking callback `fn(res)` | ||
@@ -1058,2 +1074,5 @@ * with an instanceof `Response`. | ||
// CORS | ||
if (this._withCredentials) xhr.withCredentials = true; | ||
// state change | ||
@@ -1060,0 +1079,0 @@ xhr.onreadystatechange = function(){ |
@@ -5,3 +5,3 @@ { | ||
"description": "awesome http requests", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "http", |
@@ -10,3 +10,3 @@ | ||
* Initialize a new `Emitter`. | ||
* | ||
* | ||
* @api public | ||
@@ -84,3 +84,5 @@ */ | ||
Emitter.prototype.off = function(event, fn){ | ||
Emitter.prototype.off = | ||
Emitter.prototype.removeListener = | ||
Emitter.prototype.removeAllListeners = function(event, fn){ | ||
this._callbacks = this._callbacks || {}; | ||
@@ -107,3 +109,3 @@ var callbacks = this._callbacks[event]; | ||
* @param {Mixed} ... | ||
* @return {Emitter} | ||
* @return {Emitter} | ||
*/ | ||
@@ -150,2 +152,1 @@ | ||
}; | ||
0.12.2 / 2013-02-04 | ||
================== | ||
* add test to check if response acts as a readable stream | ||
* add ReadableStream in the Response prototype. | ||
* add test to assert correct redirection when the host changes in the location header. | ||
* add default Accept-Encoding. Closes #155 | ||
* fix req.pipe() return value of original stream for node parity. Closes #171 | ||
* remove the host header when cleaning headers to properly follow the redirection. | ||
0.12.1 / 2013-01-10 | ||
@@ -3,0 +13,0 @@ ================== |
@@ -655,2 +655,18 @@ | ||
/** | ||
* Enable transmission of cookies with x-domain requests. | ||
* | ||
* Note that for this to work the origin must not be | ||
* using "Access-Control-Allow-Origin" with a wildcard, | ||
* and also must set "Access-Control-Allow-Credentials" | ||
* to "true". | ||
* | ||
* @api public | ||
*/ | ||
Request.prototype.withCredentials = function(){ | ||
this._withCredentials = true; | ||
return this; | ||
}; | ||
/** | ||
* Initiate request, invoking callback `fn(res)` | ||
@@ -674,2 +690,5 @@ * with an instanceof `Response`. | ||
// CORS | ||
if (this._withCredentials) xhr.withCredentials = true; | ||
// state change | ||
@@ -676,0 +695,0 @@ xhr.onreadystatechange = function(){ |
@@ -378,3 +378,3 @@ /*! | ||
* @param {Object} options | ||
* @return {Request} for chaining | ||
* @return {Stream} | ||
* @api public | ||
@@ -385,5 +385,6 @@ */ | ||
this.buffer(false); | ||
return this.end().req.on('response', function(res){ | ||
this.end().req.on('response', function(res){ | ||
res.pipe(stream, options); | ||
}); | ||
return stream; | ||
}; | ||
@@ -543,2 +544,3 @@ | ||
var req = this.req = mod.request(options); | ||
req.setHeader('Accept-Encoding', 'gzip, deflate'); | ||
this.protocol = url.protocol; | ||
@@ -545,0 +547,0 @@ this.host = url.host; |
@@ -24,2 +24,5 @@ | ||
* @param {Object} options | ||
* @constructor | ||
* @extends {Stream} | ||
* @implements {ReadableStream} | ||
* @api private | ||
@@ -43,2 +46,4 @@ */ | ||
res.on('end', this.emit.bind(this, 'end')); | ||
res.on('close', this.emit.bind(this, 'close')); | ||
res.on('error', this.emit.bind(this, 'error')); | ||
} | ||
@@ -53,2 +58,18 @@ | ||
/** | ||
* Implements methods of a `ReadableStream` | ||
*/ | ||
Response.prototype.destroy = function(err){ | ||
this.res.destroy(err); | ||
}; | ||
Response.prototype.pause = function(){ | ||
this.res.pause(); | ||
}; | ||
Response.prototype.resume = function(){ | ||
this.res.resume(); | ||
}; | ||
/** | ||
* Return an `Error` representative of this response. | ||
@@ -55,0 +76,0 @@ * |
@@ -147,3 +147,4 @@ | ||
delete header['cookie']; | ||
delete header['host']; | ||
return header; | ||
}; |
{ | ||
"name": "superagent", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "elegant & feature rich browser / node HTTP with a fluent API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
95324
3253
24