From 403949c26f05f4fc6efdc6008e91528b06c37560 Mon Sep 17 00:00:00 2001 From: Nuno Job Date: Wed, 24 Aug 2011 12:32:22 +0100 Subject: [PATCH] 0.6.6 > bump to latest version of request. all tests pass --- node_modules/request/main.js | 16 ++++++++++++---- package.json | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/node_modules/request/main.js b/node_modules/request/main.js index 78c472a4..c1979203 100644 --- a/node_modules/request/main.js +++ b/node_modules/request/main.js @@ -222,6 +222,7 @@ Request.prototype.request = function () { options.agent.maxSockets = options.pool.maxSockets } } + options.start = function () { options._started = true options.method = options.method || 'GET' @@ -260,7 +261,9 @@ Request.prototype.request = function () { options._redirectsFollowed = 0 // Be a good stream and emit end when the response is finished. // Hack to emit end on close because of a core bug that never fires end - response.on('close', function () {options.response.emit('end')}) + response.on('close', function () { + if (!options._ended) options.response.emit('end') + }) if (options.encoding) { if (options.dests.length !== 0) { @@ -283,10 +286,14 @@ Request.prototype.request = function () { } dest.statusCode = response.statusCode } + if (options.pipefilter) options.pipefilter(response, dest) }) response.on("data", function (chunk) {options.emit("data", chunk)}) - response.on("end", function (chunk) {options.emit("end", chunk)}) + response.on("end", function (chunk) { + options._ended = true + options.emit("end", chunk) + }) response.on("close", function () {options.emit("close")}) if (options.onResponse) { @@ -326,7 +333,8 @@ Request.prototype.request = function () { if (options.ntick) throw new Error("You cannot pipe to this stream after the first nextTick() after creation of the request stream.") options.src = src if (isReadStream(src)) { - options.headers['content-type'] = mimetypes.lookup(src.path.slice(src.path.lastIndexOf('.')+1)) + if (!options.headers['content-type'] && !options.headers['Content-Type']) + options.headers['content-type'] = mimetypes.lookup(src.path.slice(src.path.lastIndexOf('.')+1)) } else { if (src.headers) { for (i in src.headers) { @@ -436,4 +444,4 @@ request.del = function (options, callback) { if (typeof options === 'string') options = {uri:options} options.method = 'DELETE' return request(options, callback) -} +} \ No newline at end of file diff --git a/package.json b/package.json index 1affb541..5ea919ba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nano" , "description": "minimalistic couchdb driver for node.js" , "homepage": "http://github.com/dscape/nano" -, "version": "0.6.5" +, "version": "0.6.6" , "author": "Nuno Job (http://nunojob.com)" , "keywords": ["couchdb", "data", "request", "json", "nosql", "micro", "nano"] , "dependencies": {"request": "~2.0.5", "underscore": "~1.1.7"}