File tree Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,19 @@ utils.inherits(Client, events.EventEmitter);
3434module . exports = Client ;
3535
3636/**
37- * HTTP(s) client constructor
37+ * HTTP client constructor
3838 * @type HttpClient
3939 * @static
4040 */
4141Client . http = require ( './client/http' ) ;
4242
43+ /**
44+ * HTTPS client constructor
45+ * @type HttpsClient
46+ * @static
47+ */
48+ Client . https = require ( './client/https' ) ;
49+
4350/**
4451 * Fork client constructor
4552 * @type ForkClient
Original file line number Diff line number Diff line change @@ -45,9 +45,10 @@ HttpClient.prototype._request = function(request, callback) {
4545 "Accept" : "application/json"
4646 } ;
4747
48+ // let user override the headers
4849 options . headers = utils . merge ( headers , options . headers || { } ) ;
4950
50- var req = http . request ( options ) ;
51+ var req = self . _getStream ( options ) ;
5152
5253 req . on ( 'response' , function ( res ) {
5354 self . emit ( 'http response' , res ) ;
@@ -83,3 +84,13 @@ HttpClient.prototype._request = function(request, callback) {
8384 req . end ( body ) ;
8485 } ) ;
8586} ;
87+
88+ /**
89+ * Gets a stream interface to a http server
90+ * @param {Object } options An options object
91+ * @return {require('http').ClientRequest }
92+ * @api private
93+ */
94+ HttpClient . prototype . _getStream = function ( options ) {
95+ return http . request ( options || { } ) ;
96+ } ;
Original file line number Diff line number Diff line change 1+ var https = require ( 'https' ) ;
2+ var utils = require ( '../utils' ) ;
3+ var HttpClient = require ( './http' ) ;
4+
5+ /**
6+ * Constructor for a Jayson HTTPS Client
7+ * @class Jayson JSON-RPC HTTPS Client
8+ * @constructor
9+ * @extends HttpClient
10+ * @param {Object|String } [options] Optional hash of settings or a URL
11+ * @return {HttpsClient }
12+ * @api public
13+ */
14+ var HttpsClient = function ( options ) {
15+ if ( ! ( this instanceof HttpsClient ) ) return new HttpsClient ( options ) ;
16+ // just proxy to constructor for HttpClient
17+ HttpClient . call ( this , options ) ;
18+ } ;
19+ utils . inherits ( HttpsClient , HttpClient ) ;
20+
21+ module . exports = HttpsClient ;
22+
23+ /**
24+ * Gets a stream interface to a https server
25+ * @param {Object } options An options object
26+ * @return {require('https').ClientRequest }
27+ * @api private
28+ */
29+ HttpsClient . prototype . _getStream = function ( options ) {
30+ return https . request ( options || { } ) ;
31+ } ;
You can’t perform that action at this time.
0 commit comments