From 08cf6378e5c9acc27314929ced66440a8b264ef0 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Thu, 31 May 2018 12:09:09 -0700 Subject: [PATCH] Always use http-agent for hooks and triggers --- src/Controllers/HooksController.js | 14 +++++--------- src/Controllers/index.js | 3 +-- src/Options/Definitions.js | 5 ----- src/Options/index.js | 2 -- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Controllers/HooksController.js b/src/Controllers/HooksController.js index 8336ddeba4..db87c57153 100644 --- a/src/Controllers/HooksController.js +++ b/src/Controllers/HooksController.js @@ -19,13 +19,11 @@ export class HooksController { _applicationId:string; _webhookKey:string; database: any; - keepAlive: boolean; - constructor(applicationId:string, databaseController, webhookKey, keepAlive) { + constructor(applicationId:string, databaseController, webhookKey) { this._applicationId = applicationId; this._webhookKey = webhookKey; this.database = databaseController; - this.keepAlive = keepAlive; } load() { @@ -93,7 +91,7 @@ export class HooksController { } addHookToTriggers(hook) { - var wrappedFunction = wrapToHTTPRequest(hook, this._webhookKey, this.keepAlive); + var wrappedFunction = wrapToHTTPRequest(hook, this._webhookKey); wrappedFunction.url = hook.url; if (hook.className) { triggers.addTrigger(hook.triggerName, hook.className, wrappedFunction, this._applicationId) @@ -167,7 +165,7 @@ export class HooksController { } } -function wrapToHTTPRequest(hook, key, keepAlive) { +function wrapToHTTPRequest(hook, key) { return (req, res) => { const jsonBody = {}; for (var i in req) { @@ -188,10 +186,8 @@ function wrapToHTTPRequest(hook, key, keepAlive) { body: JSON.stringify(jsonBody), }; - if (keepAlive) { - const agent = hook.url.startsWith('https') ? HTTPAgents['https'] : HTTPAgents['http']; - jsonRequest.agent = agent; - } + const agent = hook.url.startsWith('https') ? HTTPAgents['https'] : HTTPAgents['http']; + jsonRequest.agent = agent; if (key) { jsonRequest.headers['X-Parse-Webhook-Key'] = key; diff --git a/src/Controllers/index.js b/src/Controllers/index.js index 19588c9b34..6bbcc7f299 100644 --- a/src/Controllers/index.js +++ b/src/Controllers/index.js @@ -150,9 +150,8 @@ export function getHooksController(options: ParseServerOptions, databaseControll const { appId, webhookKey, - hookKeepAlive, } = options; - return new HooksController(appId, databaseController, webhookKey, hookKeepAlive); + return new HooksController(appId, databaseController, webhookKey); } interface PushControlling { diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index b1514129be..8a58da95dc 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -302,11 +302,6 @@ module.exports.ParseServerOptions = { "env": "PARSE_SERVER_LIVE_QUERY_SERVER_OPTIONS", "help": "Live query server configuration options (will start the liveQuery server)", "action": parsers.objectParser - }, - "hookKeepAlive": { - "env": "PARSE_SERVER_HOOK_KEEP_ALIVE", - "help": "Keep hook HTTP connections alive", - "action": parsers.booleanParser } }; module.exports.CustomPagesOptions = { diff --git a/src/Options/index.js b/src/Options/index.js index bcdb53c8a1..e4f6c24dfb 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -131,8 +131,6 @@ export interface ParseServerOptions { startLiveQueryServer: ?boolean; /* Live query server configuration options (will start the liveQuery server) */ liveQueryServerOptions: ?LiveQueryServerOptions; - /* Keep hook HTTP connections alive */ - hookKeepAlive: ?boolean; __indexBuildCompletionCallbackForTests: ?()=>void; }