Skip to content

Commit 754c328

Browse files
committed
Merge pull request #221 from michae1/master
New option to specify http agent
2 parents dc723bc + 7532458 commit 754c328

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Also you can use `json()` and `postJson()` methods.
139139
* `followRedirects` If set will recursively follow redirects. Defaults to `true`.
140140
* `timeout` If set, will emit the timeout event when the response does not return within the said value (in ms)
141141
* `rejectUnauthorized` If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default true.
142-
142+
* `agent` [HTTP Agent][http-agent-doc] instance to use. If not defined [globalAgent][http-global-agent-doc] will be used. If false opts out of connection pooling with an Agent, defaults request to Connection: close.
143143

144144
Example usage
145145
-------------
@@ -225,3 +225,6 @@ rest.putJson('http://example.com/action', jsonData).on('complete', function(data
225225
TODO
226226
----
227227
* What do you need? Let me know or fork.
228+
229+
[http-agent-doc]: https://nodejs.org/api/http.html#http_class_http_agent
230+
[http-global-agent-doc]: https://nodejs.org/api/http.html#http_http_globalagent

lib/restler.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ function Request(uri, options) {
7878
path: this._fullPath(),
7979
method: this.options.method,
8080
headers: this.headers,
81-
rejectUnauthorized: this.options.rejectUnauthorized
81+
rejectUnauthorized: this.options.rejectUnauthorized,
82+
agent: this.options.agent
8283
});
8384

8485
this._makeRequest();

0 commit comments

Comments
 (0)