Comparing version 2.36.0 to 2.37.0
@@ -26,2 +26,5 @@ var optional = require('./optional') | ||
}; | ||
RequestJar.prototype.getCookies = function(uri) { | ||
return this._jar.getCookiesSync(uri); | ||
}; | ||
@@ -33,3 +36,4 @@ exports.jar = function() { | ||
setCookie: function(){}, | ||
getCookieString: function(){} | ||
getCookieString: function(){}, | ||
getCookies: function(){} | ||
}; | ||
@@ -36,0 +40,0 @@ } |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "2.36.0", | ||
"version": "2.37.0", | ||
"author": "Mikeal Rogers <mikeal.rogers@gmail.com>", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
}, | ||
"license": "Apache, Version 2.0", | ||
"license": "Apache-2.0", | ||
"engines": [ | ||
@@ -29,3 +29,3 @@ "node >= 0.8.0" | ||
"json-stringify-safe": "~5.0.0", | ||
"mime": "~1.2.9", | ||
"mime-types": "~1.0.1", | ||
"forever-agent": "~0.5.0", | ||
@@ -40,3 +40,3 @@ "node-uuid": "~1.4.0" | ||
"oauth-sign": "~0.3.0", | ||
"hawk": "~1.0.0", | ||
"hawk": "1.1.1", | ||
"aws-sign2": "~0.5.0" | ||
@@ -43,0 +43,0 @@ }, |
@@ -242,3 +242,3 @@ # Request -- Simplified HTTP client | ||
* `body` - entity body for PATCH, POST and PUT requests. Must be a `Buffer` or `String`. | ||
* `form` - when passed an object, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded; charset=utf-8` header. When passed no options, a `FormData` instance is returned (and is piped to request). | ||
* `form` - when passed an object or a querystring, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded; charset=utf-8` header. When passed no options, a `FormData` instance is returned (and is piped to request). | ||
* `auth` - A hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). See documentation above. | ||
@@ -262,2 +262,3 @@ * `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON. | ||
* `localAddress` - Local interface to bind for network connections. | ||
* `gzip` - If `true`, add an `Accept-Encoding` header to request compressed content encodings from the server (if not already present) and decode supported content encodings in the response. | ||
@@ -398,1 +399,12 @@ | ||
``` | ||
To inspect your cookie jar after a request | ||
```javascript | ||
var j = request.jar() | ||
request({url: 'http://www.google.com', jar: j}, function () { | ||
var cookie_string = j.getCookieString(uri); // "key1=value1; key2=value2; ..." | ||
var cookies = j.getCookies(uri); | ||
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] | ||
}) | ||
``` |
@@ -11,2 +11,3 @@ var optional = require('./lib/optional') | ||
, crypto = require('crypto') | ||
, zlib = require('zlib') | ||
@@ -18,3 +19,3 @@ , oauth = optional('oauth-sign') | ||
, uuid = require('node-uuid') | ||
, mime = require('mime') | ||
, mime = require('mime-types') | ||
, tunnel = optional('tunnel-agent') | ||
@@ -294,2 +295,6 @@ , _safeStringify = require('json-stringify-safe') | ||
if (self.gzip && !self.hasHeader('accept-encoding')) { | ||
self.setHeader('accept-encoding', 'gzip') | ||
} | ||
if (self.uri.auth && !self.hasHeader('authorization')) { | ||
@@ -402,3 +407,3 @@ var authPieces = self.uri.auth.split(':').map(function(item){ return querystring.unescape(item) }) | ||
var length = self._form.getLengthSync() | ||
self.setHeader('content-length', length) | ||
if (!self.hasHeader('content-length')) self.setHeader('content-length', length) | ||
} catch(e){} | ||
@@ -638,2 +643,7 @@ self._form.pipe(self) | ||
} | ||
if (options.secureOptions) { | ||
if (poolKey) poolKey += ':' | ||
poolKey += options.secureOptions | ||
} | ||
} | ||
@@ -719,3 +729,5 @@ | ||
if (response.connection.listeners('error').indexOf(self._parserErrorHandler) === -1) { | ||
// The check on response.connection is a workaround for browserify. | ||
if (response.connection && response.connection.listeners('error').indexOf(self._parserErrorHandler) === -1) { | ||
response.connection.setMaxListeners(0) | ||
response.connection.once('error', self._parserErrorHandler) | ||
@@ -729,3 +741,4 @@ } | ||
if (self._paused) response.pause() | ||
else response.resume() | ||
// Check that response.resume is defined. Workaround for browserify. | ||
else response.resume && response.resume() | ||
@@ -923,2 +936,22 @@ self.response = response | ||
var dataStream | ||
if (self.gzip) { | ||
var contentEncoding = response.headers["content-encoding"] || "identity" | ||
contentEncoding = contentEncoding.trim().toLowerCase() | ||
if (contentEncoding === "gzip") { | ||
dataStream = zlib.createGunzip() | ||
response.pipe(dataStream) | ||
} else { | ||
// Since previous versions didn't check for Content-Encoding header, | ||
// ignore any invalid values to preserve backwards-compatibility | ||
if (contentEncoding !== "identity") { | ||
debug("ignoring unrecognized Content-Encoding " + contentEncoding) | ||
} | ||
dataStream = response | ||
} | ||
} else { | ||
dataStream = response | ||
} | ||
if (self.encoding) { | ||
@@ -928,3 +961,4 @@ if (self.dests.length !== 0) { | ||
} else { | ||
response.setEncoding(self.encoding) | ||
// gz streams don't have setEncoding in v0.8 | ||
if (dataStream.setEncoding) dataStream.setEncoding(self.encoding) | ||
} | ||
@@ -939,11 +973,11 @@ } | ||
response.on("data", function (chunk) { | ||
dataStream.on("data", function (chunk) { | ||
self._destdata = true | ||
self.emit("data", chunk) | ||
}) | ||
response.on("end", function (chunk) { | ||
dataStream.on("end", function (chunk) { | ||
self._ended = true | ||
self.emit("end", chunk) | ||
}) | ||
response.on("close", function () {self.emit("close")}) | ||
dataStream.on("close", function () {self.emit("close")}) | ||
@@ -1043,3 +1077,7 @@ if (self.callback) { | ||
for (var i in response.headers) { | ||
dest.setHeader(i, response.headers[i]) | ||
// If the response content is being decoded, the Content-Encoding header | ||
// of the response doesn't represent the piped content, so don't pass it. | ||
if (!this.gzip || i !== 'content-encoding') { | ||
dest.setHeader(i, response.headers[i]) | ||
} | ||
} | ||
@@ -1097,3 +1135,3 @@ dest.statusCode = response.statusCode | ||
this.setHeader('content-type', 'application/x-www-form-urlencoded; charset=utf-8') | ||
this.body = qs.stringify(form).toString('utf8') | ||
this.body = (typeof form === 'string') ? form.toString('utf8') : qs.stringify(form).toString('utf8') | ||
return this | ||
@@ -1100,0 +1138,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
96588
0
1444
408
+ Addedmime-types@~1.0.1
+ Addedhawk@1.1.1(transitive)
+ Addedmime-types@1.0.2(transitive)
- Removedmime@~1.2.9
- Removedhawk@1.0.0(transitive)