Skip to content

Commit

Permalink
Provide an 'https' client to talk to Riak over ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Aug 11, 2011
1 parent 8d4f2fb commit fe5eaa0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/http_client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ http = require 'http'

class HttpClient extends Client
constructor: (options) ->
options = options || {}
options = Utils.mixin true, {}, Meta.defaults, options
@_http = options.http || http
super options

get: (bucket, key, options...) ->
Expand Down Expand Up @@ -212,7 +214,7 @@ class HttpClient extends Client
meta.headers = meta.toHeaders()
Client.debug "#{meta.method} #{meta.path}", meta

request = http.request meta, (response) =>
request = @_http.request meta, (response) =>

# using meta as options, to which the HTTP Agent is attached
# we don't want to carry this around in a Meta
Expand Down
11 changes: 11 additions & 0 deletions src/https_client.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
https = require 'https'
HttpClient = require './http_client'

{ EventEmitter } = require 'events'

class HttpsClient extends HttpClient
constructor: (options) ->
options.http = options.http || https
super options

module.exports = HttpsClient
8 changes: 7 additions & 1 deletion src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module.exports =
# Gets a new client instance using the HTTP REST api.
http: (options) -> new @HttpClient options

# Gets a new client instance using the HTTP REST api over SSL.
https: (options) -> new @HttpsClient options

# Gets a new client instance using the protocol buffer api.
protobuf: (options) ->
options ||= {}
Expand All @@ -29,6 +32,9 @@ module.exports =
module.exports.__defineGetter__ 'HttpClient', ->
@_httpClient ||= require './http_client'

module.exports.__defineGetter__ 'HttpsClient', ->
@_httpsClient ||= require './https_client'

module.exports.__defineGetter__ 'ProtobufClient', ->
@_pbcClient ||= require './protobuf_client'

Expand All @@ -39,4 +45,4 @@ module.exports.__defineGetter__ 'TestServer', ->
@_testServer ||= require './test_server'

module.exports.__defineGetter__ 'SessionStore', ->
@_sessionStore ||= require './session_store'
@_sessionStore ||= require './session_store'

0 comments on commit fe5eaa0

Please sign in to comment.