From d094d504fef670cf84524e9b984a737597fd324b Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 13 Jan 2016 18:37:29 +0100 Subject: [PATCH] Remove IE9 hack in quality profiles --- .../qualityprofile/ws/CreateAction.java | 16 +-------------- .../qualityprofile/ws/CreateActionTest.java | 20 ------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java index cb1ab9d31fa..f9c41bac66f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java @@ -119,7 +119,7 @@ public class CreateAction implements QProfileWsAction { } dbSession.commit(); - response.stream().setMediaType(guessMediaType(request)); + response.stream().setMediaType(request.getMediaType()); JsonWriter jsonWriter = JsonWriter.of(new OutputStreamWriter(response.stream().output(), StandardCharsets.UTF_8)); writeResult(jsonWriter, result); } finally { @@ -127,20 +127,6 @@ public class CreateAction implements QProfileWsAction { } } - private static String guessMediaType(Request request) { - if (request.getMediaType().contains("html")) { - // this is a hack for IE. - // The form which uploads files (for example PMD or Findbugs configuration files) opens a popup - // to download files if the response type header is application/json. Changing the response type to text/plain, - // even if response body is JSON, fixes the bug. - // This will be fixed in 5.3 when support of IE9/10 will be dropped in order to use - // more recent JS libs. - // We detect that caller is IE because it asks for application/html or text/html - return MediaTypes.TXT; - } - return request.getMediaType(); - } - private void writeResult(JsonWriter json, QProfileResult result) { String language = result.profile().getLanguage(); json.beginObject().name("profile").beginObject() diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java index 2a89e800374..1ff538bb890 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java @@ -64,24 +64,4 @@ public class CreateActionTest { JsonAssert.assertJson(response.getInput()).isSimilarTo(getClass().getResource("CreateActionTest/create-no-importer.json")); assertThat(response.getMediaType()).isEqualTo(MediaTypes.JSON); } - - /** - * Do not return JSON content type header on IE. - */ - @Test - public void test_ie_hack() throws Exception { - CreateAction underTest = new CreateAction(db.getDbClient(), new QProfileFactory(deprecatedDbClient), null, LanguageTesting.newLanguages("xoo"), userSessionRule); - WsActionTester wsTester = new WsActionTester(underTest); - userSessionRule.login("admin").setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN); - - TestResponse response = wsTester.newRequest() - .setMethod("POST") - // IE asks for application/html or text/html - .setMediaType("application/html") - .setParam("language", "xoo") - .setParam("name", "Yeehaw!") - .execute(); - assertThat(response.getMediaType()).isEqualTo(MediaTypes.TXT); - - } } -- 2.39.5