javascript: use persistent http connections #144
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described in #143, Alternator.js is currently broken for https endpoints for a couple of reasons, namely a hard-coded port number, and using the wrong agent object (
http.Agent, instead ofhttps.Agent).This PR has three commits: one to fix each of those two issues, and one to use persistent http connections (passing
{ keepAlive: true }to the agent). To set the agent ininit, I had to move some other code into there as well, otherwise it runs before agent is initialised.With regards to the agent options, I would recommend also allowing the caller of
initto pass their own options in (and then merge the two objects), but I didn't want to include too much in one PR.I'm happy to squash, revert, or edit any parts of this (or to extend it with my extra options suggestion).