mostlyserious/riak-js — pull request #178 by calebcase (2013-06-04 15:00:14+00:00)
Title: Add HTTPS support.

This adds the option to specify ssl: true which results in an HTTPS connection. Unfortunately it required working around a few oddities:

1. http-request.js: 'meta' is passed directly to the http.request method, but it contains key that would normally be meaningless (e.g. 'key', 'bucket', etc). However, these normally harmless keys cause issues with https.request because 'key' has a special meaning there. I've worked around this by lifting the options for request out of meta manually for HTTPS. It might be better to do this for HTTP as well (and potentially integrate this into meta's mapping system).
1. http-search-client.js: Doesn't maintain the full set of options passed in. It selectively uses only host, port, and client. This prevents additional options such as rejectUnauthorized from being set. I've reversed the way that the _defaults is set so that it acts more like a default without preventing additional keys. It might be better to use an external library to merge the objects rather than the manual shallow copy.
1. http-search-client.js: _run appears to have a bug where it will dereference 'data' even if an error has occurred and 'data' is undefined.
1. It is unclear to me how best to reuse the tests with an HTTPS connection. For now I've simply replaced the HttpClient creations with HTTPS varieties that will work with a self-signed certificate.