petersirka/node-couchdb — pull request #1 by dlkinney (2013-06-27 20:15:57+00:00)
Title: Converted direct use of http module to conditional http or https

In the `attachment()` and `upload()` methods, the `http` module was being used without regard to the protocol defined in the CouchDB URL. This caused the following error when used for a CouchDB server hosted at an HTTPS URL:

http.js:1810
throw new Error('Protocol:' + options.protocol + ' not supported.');
^
Error: Protocol:https: not supported.
at Object.exports.request (http.js:1810:11)
at Object.exports.get (http.js:1817:21)
at CouchDB.attachment (/project_path/node_modules/coucher/index.js:519:10)
at /project_path/web.js:124:17
at IncomingMessage. (/project_path/node_modules/coucher/index.js:212:4)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:910:16
at process._tickCallback (node.js:415:13)

This pull request duplicates the `var con = ...` logic used elsewhere in the Coucher `index.js` file to determine whether the `http` or `https` module should be used to create the connection to CouchDB.

I discovered this issue while building a project running on Node.js version 0.10.12, but the logic does not appear to have any relationship to the Node version.