ApiServlet: move setting of response type up in the layer Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6ec1a1b6 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6ec1a1b6 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6ec1a1b6 Branch: refs/heads/master Commit: 6ec1a1b604e32ba000f72a8978e41b2799a9acd8 Parents: 7434f1b Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Tue Aug 12 09:14:50 2014 +0200 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Tue Aug 12 12:01:31 2014 +0200 ---------------------------------------------------------------------- server/src/com/cloud/api/ApiServlet.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6ec1a1b6/server/src/com/cloud/api/ApiServlet.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java index 5a8cf94..d94894a 100644 --- a/server/src/com/cloud/api/ApiServlet.java +++ b/server/src/com/cloud/api/ApiServlet.java @@ -143,6 +143,12 @@ public class ApiServlet extends HttpServlet { } try { + if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + resp.setContentType(ApiServer.getJsonContentType() + "; charset=UTF-8"); + } else { + resp.setContentType("text/xml; charset=UTF-8"); + } + HttpSession session = req.getSession(false); final Object[] responseTypeParam = params.get(ApiConstants.RESPONSE); if (responseTypeParam != null) { @@ -301,12 +307,6 @@ public class ApiServlet extends HttpServlet { // FIXME: rather than isError, we might was to pass in the status code to give more flexibility private void writeResponse(final HttpServletResponse resp, final String response, final int responseCode, final String responseType) { try { - if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - resp.setContentType(ApiServer.getJsonContentType() + "; charset=UTF-8"); - } else { - resp.setContentType("text/xml; charset=UTF-8"); - } - resp.setStatus(responseCode); resp.getWriter().print(response); } catch (final IOException ioex) {