You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/04/20 01:50:29 UTC

[incubator-servicecomb-java-chassis] 05/09: SCB-483 set correct content-type for download

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 8679a91508190986b50f9d39d2e229d8bbd8eb87
Author: wujimin <wu...@huawei.com>
AuthorDate: Wed Apr 18 15:24:35 2018 +0800

    SCB-483 set correct content-type for download
---
 .../apache/servicecomb/common/rest/AbstractRestInvocation.java |  1 -
 .../common/rest/filter/inner/ServerRestArgsFilter.java         |  2 ++
 .../servicecomb/common/rest/TestAbstractRestInvocation.java    | 10 +++-------
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java
index 89be43e..9a3769b 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java
@@ -212,7 +212,6 @@ public abstract class AbstractRestInvocation {
       }
     }
     responseEx.setStatus(response.getStatusCode(), response.getReasonPhrase());
-    responseEx.setContentType(produceProcessor.getName() + "; charset=utf-8");
     responseEx.setAttribute(RestConst.INVOCATION_HANDLER_RESPONSE, response);
     responseEx.setAttribute(RestConst.INVOCATION_HANDLER_PROCESSOR, produceProcessor);
 
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/inner/ServerRestArgsFilter.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/inner/ServerRestArgsFilter.java
index f33e0af..f740568 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/inner/ServerRestArgsFilter.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/inner/ServerRestArgsFilter.java
@@ -67,6 +67,8 @@ public class ServerRestArgsFilter implements HttpServerFilter {
       return responseEx.sendPart((Part) body);
     }
 
+    responseEx.setContentType(produceProcessor.getName() + "; charset=utf-8");
+
     CompletableFuture<Void> future = new CompletableFuture<Void>();
     try (BufferOutputStream output = new BufferOutputStream(Unpooled.compositeBuffer())) {
       produceProcessor.encodeResponse(output, body);
diff --git a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java
index 6d82bc6..811ea47 100644
--- a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java
+++ b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java
@@ -445,7 +445,7 @@ public class TestAbstractRestInvocation {
         response.getReasonPhrase();
         result = "reason";
         response.getResult();
-        result = new Error("stop");
+        result = "result";
       }
     };
 
@@ -482,12 +482,8 @@ public class TestAbstractRestInvocation {
 
     initRestInvocation();
 
-    try {
-      restInvocation.sendResponse(response);
-      Assert.fail("must throw exception");
-    } catch (Error e) {
-      Assert.assertEquals(expected, result);
-    }
+    restInvocation.sendResponse(response);
+    Assert.assertEquals(expected, result);
   }
 
   @Test

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.