]> source.dussan.org Git - sonarqube.git/commitdiff
Remove IE9 hack in quality profiles
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 13 Jan 2016 17:37:29 +0000 (18:37 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 14 Jan 2016 09:02:51 +0000 (10:02 +0100)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java

index cb1ab9d31fa6725a88d3e692403328c96a270739..f9c41bac66fcf04c0ad99b917ae3e6a702a2a4f7 100644 (file)
@@ -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()
index 2a89e800374c00707cfacc32b8bc6359a67ec40d..1ff538bb89064e6b711536b4b935dc6f37a82d11 100644 (file)
@@ -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);
-
-  }
 }