DLAB-2 disabled gzip handler for guacamole servlet
diff --git a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java
index fcacef0..bbff7b9 100644
--- a/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java
+++ b/services/provisioning-service/src/main/java/com/epam/dlab/backendapi/resources/base/KeyResource.java
@@ -46,13 +46,11 @@
 
 	private final KeyService keyService;
 	private final ProvisioningServiceApplicationConfiguration configuration;
-	private final String keyContent;
 
 	@Inject
 	public KeyResource(KeyService keyService, ProvisioningServiceApplicationConfiguration configuration) {
 		this.keyService = keyService;
 		this.configuration = configuration;
-		this.keyContent = keyService.getAdminKey();
 	}
 
 
@@ -69,7 +67,7 @@
 
 	@GET
 	public String getAdminKey(@Auth UserInfo userInfo) {
-		return keyContent;
+		return keyService.getAdminKey();
 	}
 
 	private void replaceKeyfile(ReuploadKeyDTO dto) throws IOException {
diff --git a/services/self-service/self-service.yml b/services/self-service/self-service.yml
index 809d04d..855950d 100644
--- a/services/self-service/self-service.yml
+++ b/services/self-service/self-service.yml
@@ -67,8 +67,6 @@
 </#if>
 
 server:
-  gzip:
-    enabled: false
   requestLog:
     appenders:
     - type: file
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java
index 1a8f59b..979464f 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/SelfServiceApplication.java
@@ -48,11 +48,15 @@
 import io.dropwizard.assets.AssetsBundle;
 import io.dropwizard.forms.MultiPartBundle;
 import io.dropwizard.jersey.setup.JerseyEnvironment;
+import io.dropwizard.jetty.BiDiGzipHandler;
 import io.dropwizard.setup.Bootstrap;
 import io.dropwizard.setup.Environment;
 import io.federecio.dropwizard.swagger.SwaggerBundle;
 import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
 import lombok.extern.slf4j.Slf4j;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.HandlerWrapper;
 
 import javax.servlet.DispatcherType;
 import java.util.EnumSet;
@@ -62,6 +66,7 @@
  */
 @Slf4j
 public class SelfServiceApplication extends Application<SelfServiceApplicationConfiguration> {
+	private static final String GUACAMOLE_SERVLET_PATH = "/api/tunnel";
 	private static Injector appInjector;
 
 	public static Injector getInjector() {
@@ -110,6 +115,7 @@
 				new RestoreHandlerStartupListener(injector.getInstance(Key.get(RESTService.class,
 						Names.named(ServiceConsts.PROVISIONING_SERVICE_NAME))));
 		environment.lifecycle().addServerLifecycleListener(restoreHandlerStartupListener);
+		environment.lifecycle().addServerLifecycleListener(this::disableGzipHandlerForGuacamoleServlet);
 		environment.lifecycle().manage(injector.getInstance(IndexCreator.class));
 		environment.lifecycle().manage(injector.getInstance(EnvStatusListener.class));
 		environment.lifecycle().manage(injector.getInstance(ExploratoryLibCache.class));
@@ -120,7 +126,7 @@
 
 		final String guacamoleServletName = "GuacamoleServlet";
 		environment.servlets().addServlet(guacamoleServletName, injector.getInstance(GuacamoleServlet.class))
-				.addMapping("/api/tunnel");
+				.addMapping(GUACAMOLE_SERVLET_PATH);
 		environment.servlets().addFilter("GuacamoleSecurityFilter",
 				injector.getInstance(GuacamoleSecurityFilter.class))
 				.addMappingForServletNames(EnumSet.allOf(DispatcherType.class), true, guacamoleServletName);
@@ -169,6 +175,17 @@
 		jersey.register(injector.getInstance(ApplicationSettingResource.class));
 	}
 
+	private void disableGzipHandlerForGuacamoleServlet(Server server) {
+		Handler handler = server.getHandler();
+		while (handler instanceof HandlerWrapper) {
+			handler = ((HandlerWrapper) handler).getHandler();
+			if (handler instanceof BiDiGzipHandler) {
+				log.debug("Disabling Gzip handler for guacamole servlet");
+				((BiDiGzipHandler) handler).setExcludedPaths(GUACAMOLE_SERVLET_PATH);
+			}
+		}
+	}
+
 	private void applyMongoMigration(SelfServiceApplicationConfiguration configuration) {
 		final MongoServiceFactory mongoFactory = configuration.getMongoFactory();