From e6b3a56d246be2eac80a1dfeba67aaba8b05ba8b Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Tue, 13 Feb 2024 07:20:58 +0100 Subject: [PATCH] Uninstall default bottle plugins By default, bottle installs two plugins: `JSONPlugin` and `TemplatePlugin`. `TemplatePlugin` is always a no-op, because none of the routes we use (like `/ready`) have a template parameter. `JSONPlugin` could have been useful were it actually serializing all json messages. Instead it only deals with dictionaries. Ycmd has always had `ycmd.handlers._JsonResponse` and we will need to keep it that way. `_JsonResponse` makes `JSONPlugin` a no-op too, because, by the time we get to the `JSONPlugin.apply()` the response is always a str already. `Bottle.uninstall()` can be passed: 1. An instance of an installed plugins, to uninstall that one plugin. 2. A type, to uninstall all plugins of that type. 3. `True`, to uninstall all plugins. Since we are uninstalling all default plugins, we can just do `handlers.app.uninstall( True )` and then install the plugins we care about - `ycmd.HmacPlugin` and `ycmd.WatchdogPlugin`. --- ycmd/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ycmd/__main__.py b/ycmd/__main__.py index 512c5974c8..5367eea085 100644 --- a/ycmd/__main__.py +++ b/ycmd/__main__.py @@ -203,6 +203,7 @@ def Main(): args.stderr, args.keep_logfiles ) atexit.register( handlers.ServerCleanup ) + handlers.app.uninstall( True ) handlers.app.install( WatchdogPlugin( args.idle_suicide_seconds, args.check_interval_seconds ) ) handlers.app.install( HmacPlugin( hmac_secret ) )