diff --git a/src/tap/ADQLExecutor.java b/src/tap/ADQLExecutor.java index fd65069243f83dbb90a2a99998c37d3c8f085445..a0ffd3e2767da702839e40aeb05bbb0aa97b6dfc 100644 --- a/src/tap/ADQLExecutor.java +++ b/src/tap/ADQLExecutor.java @@ -37,6 +37,7 @@ import tap.parameters.DALIUpload; import tap.parameters.TAPParameters; import tap.upload.Uploader; import uws.UWSException; +import uws.UWSToolBox; import uws.job.JobThread; import uws.job.Result; import uws.service.log.UWSLog.LogLevel; @@ -610,6 +611,9 @@ public class ADQLExecutor { // Set the HTTP content type to the MIME type of the result format: response.setContentType(formatter.getMimeType()); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Write the formatted result in the HTTP response output: start = System.currentTimeMillis(); writeResult(queryResult, formatter, response.getOutputStream()); diff --git a/src/tap/error/DefaultTAPErrorWriter.java b/src/tap/error/DefaultTAPErrorWriter.java index 22a542c32ab2c1710c1472e4a1352c2a72276c89..6b390cb1f420fc606a203343169276d8581faafd 100644 --- a/src/tap/error/DefaultTAPErrorWriter.java +++ b/src/tap/error/DefaultTAPErrorWriter.java @@ -41,6 +41,7 @@ import tap.formatter.VOTableFormat; import tap.log.DefaultTAPLog; import tap.log.TAPLog; import uws.UWSException; +import uws.UWSToolBox; import uws.job.ErrorSummary; import uws.job.ErrorType; import uws.job.UWSJob; @@ -193,6 +194,9 @@ public class DefaultTAPErrorWriter implements ServiceErrorWriter { // Set the MIME type of the answer (XML for a VOTable document): response.setContentType("application/xml"); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + }catch(IllegalStateException ise){ /* If it is not possible any more to reset the response header and body, * the error is anyway written in order to corrupt the HTTP response. diff --git a/src/tap/metadata/TAPMetadata.java b/src/tap/metadata/TAPMetadata.java index 77dd7320c6e4d12896f9ff1ea1b2c9d7a3bba15f..11cad6c039a768d9ba73348fa2d9996e39ff8d42 100644 --- a/src/tap/metadata/TAPMetadata.java +++ b/src/tap/metadata/TAPMetadata.java @@ -456,6 +456,7 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour @Override public boolean executeResource(HttpServletRequest request, HttpServletResponse response) throws IOException{ response.setContentType("application/xml"); + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); PrintWriter writer = response.getWriter(); write(writer); diff --git a/src/tap/resource/Availability.java b/src/tap/resource/Availability.java index 003db0a66c78c1b059e34842d8255a3b2114e452..aede393998a18765a953cd156eb06da7300e64ef 100644 --- a/src/tap/resource/Availability.java +++ b/src/tap/resource/Availability.java @@ -16,7 +16,7 @@ package tap.resource; * You should have received a copy of the GNU Lesser General Public License * along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -31,12 +31,13 @@ import javax.servlet.http.HttpServletResponse; import tap.ServiceConnection; import tap.TAPException; import uk.ac.starlink.votable.VOSerializer; +import uws.UWSToolBox; /** * <p>TAP resource describing the availability of a TAP service.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 2.0 (09/2014) + * @version 2.0 (04/2015) */ public class Availability implements TAPResource, VOSIResource { @@ -109,6 +110,9 @@ public class Availability implements TAPResource, VOSIResource { // Set the response MIME type (XML): response.setContentType("text/xml"); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Get the output stream: PrintWriter pw = response.getWriter(); diff --git a/src/tap/resource/Capabilities.java b/src/tap/resource/Capabilities.java index 4afdcca2b11eda6e39599be855025306f3d2bd2b..e8b2aa744fcc9fd70b3162530a18030af61ab43f 100644 --- a/src/tap/resource/Capabilities.java +++ b/src/tap/resource/Capabilities.java @@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import tap.TAPException; import uk.ac.starlink.votable.VOSerializer; +import uws.UWSToolBox; /** * <p>TAP resource describing the capabilities of a TAP service.</p> @@ -38,7 +39,7 @@ import uk.ac.starlink.votable.VOSerializer; * <p>This resource just return an XML document giving a description of the TAP service and list all its VOSI resources.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 2.0 (02/2015) + * @version 2.0 (04/2015) */ public class Capabilities implements TAPResource, VOSIResource { @@ -112,6 +113,9 @@ public class Capabilities implements TAPResource, VOSIResource { // Set the response MIME type (XML): response.setContentType("application/xml"); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Get the response stream: PrintWriter out = response.getWriter(); diff --git a/src/tap/resource/HomePage.java b/src/tap/resource/HomePage.java index 280ab99b0132c8a1328fb4ad1ecf80fca8c07ffd..b0f5551b0703bc811c87a4854a6192f75f0cb3f7 100644 --- a/src/tap/resource/HomePage.java +++ b/src/tap/resource/HomePage.java @@ -120,8 +120,8 @@ public class HomePage implements TAPResource { // Set the content type: response.setContentType(tap.homePageMimeType); - // set character encoding: - response.setCharacterEncoding("UTF-8"); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); // Get the character writer: PrintWriter writer = response.getWriter(); @@ -216,6 +216,9 @@ public class HomePage implements TAPResource { // Set the content type: HTML document response.setContentType("text/html"); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Write the home page: writer.println("<html><head><title>TAP HOME PAGE</title></head><body><h1 style=\"text-align: center\">TAP HOME PAGE</h1><h2>Available resources:</h2><ul>"); for(TAPResource res : tap.resources.values()) diff --git a/src/tap/resource/TAP.java b/src/tap/resource/TAP.java index 57f15187e5e663bb4a3a9110a9238b7461fd08e6..b8a399b4384bfc7df665e83bbb6ef699f55533d6 100644 --- a/src/tap/resource/TAP.java +++ b/src/tap/resource/TAP.java @@ -825,6 +825,9 @@ public class TAP implements VOSIResource { throw new TAPException(ue); } + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Display the TAP Home Page: if (resourceName.length() == 0){ resourceName = homePage.getName(); diff --git a/src/uws/UWSToolBox.java b/src/uws/UWSToolBox.java index 2658240d2eaea587eab1c99c6e756d9058ccf38f..b582178209eaaef4f5cf9d6f6f2daa8eb27f58e2 100644 --- a/src/uws/UWSToolBox.java +++ b/src/uws/UWSToolBox.java @@ -54,10 +54,15 @@ import uws.service.request.UploadFile; * Some useful functions for the managing of a UWS service. * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (03/2015) + * @version 4.1 (04/2015) */ public class UWSToolBox { + /** + * Default character encoding for all HTTP response sent by this library. + * @since 4.1 */ + public final static String DEFAULT_CHAR_ENCODING = "UTF-8"; + private static UWSLog defaultLogger = null; /** <b>THIS CLASS CAN'T BE INSTANTIATED !</b> */ @@ -504,6 +509,9 @@ public class UWSToolBox { if (mimeType != null) response.setContentType(mimeType); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Set the HTTP content length: if (contentSize > 0) response.setContentLength((int)contentSize); diff --git a/src/uws/service/UWSService.java b/src/uws/service/UWSService.java index 4283ff5ddf54268883757f4543ce0b54f1a34d4f..c0e65dc70c629cae960cecd1cacccdf2bfc726fb 100644 --- a/src/uws/service/UWSService.java +++ b/src/uws/service/UWSService.java @@ -1128,6 +1128,9 @@ public class UWSService implements UWS { // Identify the user: user = UWSToolBox.getUser(request, userIdentifier); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Apply the appropriate UWS action: for(int i = 0; action == null && i < uwsActions.size(); i++){ if (uwsActions.get(i).match(urlInterpreter, user, request)){ @@ -1217,6 +1220,7 @@ public class UWSService implements UWS { public void redirect(String url, HttpServletRequest request, JobOwner user, String uwsAction, HttpServletResponse response) throws IOException, UWSException{ response.setStatus(HttpServletResponse.SC_SEE_OTHER); response.setContentType(request.getContentType()); + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); response.setHeader("Location", url); response.flushBuffer(); } diff --git a/src/uws/service/UWSServlet.java b/src/uws/service/UWSServlet.java index 9a47f3a6b5ad09722897e4bc58f3cd089e117db8..1f62ca76f8247f98400f7e159eb0819dd0487806 100644 --- a/src/uws/service/UWSServlet.java +++ b/src/uws/service/UWSServlet.java @@ -342,6 +342,9 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory // Identify the user: user = UWSToolBox.getUser(req, userIdentifier); + // Set the character encoding: + resp.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // METHOD GET: if (method.equals("GET")){ // HOME PAGE: @@ -489,6 +492,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory protected void writeHomePage(UWSUrl requestUrl, HttpServletRequest req, HttpServletResponse resp, JobOwner user) throws UWSException, ServletException, IOException{ UWSSerializer serializer = getSerializer(req.getHeader("Accept")); resp.setContentType(serializer.getMimeType()); + resp.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); String serialization; try{ serialization = serializer.getUWS(this); @@ -514,6 +518,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory // Write the jobs list: UWSSerializer serializer = getSerializer(req.getHeader("Accept")); resp.setContentType(serializer.getMimeType()); + resp.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); try{ jobsList.serialize(resp.getOutputStream(), serializer, user); }catch(Exception e){ @@ -585,6 +590,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory // Write the job summary: UWSSerializer serializer = getSerializer(req.getHeader("Accept")); resp.setContentType(serializer.getMimeType()); + resp.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); try{ job.serialize(resp.getOutputStream(), serializer, user); }catch(Exception e){ @@ -664,11 +670,15 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory UWSSerializer serializer = getSerializer(req.getHeader("Accept")); String uwsField = attributes[0]; boolean jobSerialization = false; + // Set the content type: if (uwsField == null || uwsField.trim().isEmpty() || (attributes.length <= 1 && (uwsField.equalsIgnoreCase(UWSJob.PARAM_ERROR_SUMMARY) || uwsField.equalsIgnoreCase(UWSJob.PARAM_RESULTS) || uwsField.equalsIgnoreCase(UWSJob.PARAM_PARAMETERS)))){ resp.setContentType(serializer.getMimeType()); jobSerialization = true; }else resp.setContentType("text/plain"); + // Set the character encoding: + resp.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Serialize the selected attribute: try{ job.serialize(resp.getOutputStream(), attributes, serializer); }catch(Exception e){ @@ -766,6 +776,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory public void redirect(String url, HttpServletRequest request, JobOwner user, String uwsAction, HttpServletResponse response) throws ServletException, IOException{ response.setStatus(HttpServletResponse.SC_SEE_OTHER); response.setContentType(request.getContentType()); + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); response.setHeader("Location", url); response.flushBuffer(); } diff --git a/src/uws/service/actions/AddJob.java b/src/uws/service/actions/AddJob.java index 5dd182b4b29ef1bfc289902343df18348caee7ef..2d5853e55acf94b67e98a2376709044812a946e9 100644 --- a/src/uws/service/actions/AddJob.java +++ b/src/uws/service/actions/AddJob.java @@ -16,7 +16,7 @@ package uws.service.actions; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -43,7 +43,7 @@ import uws.service.log.UWSLog.LogLevel; * The response of this action is a redirection to the new job resource (that is to say: a redirection to the job summary of the new job).</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (08/2014) + * @version 4.1 (04/2015) */ public class AddJob extends UWSAction { private static final long serialVersionUID = 1L; diff --git a/src/uws/service/actions/DestroyJob.java b/src/uws/service/actions/DestroyJob.java index 2aeb76a5986640e21cffa19b80fef75d6ff13ed5..de75e204288973db2118aad73e868bbcd1a9eae5 100644 --- a/src/uws/service/actions/DestroyJob.java +++ b/src/uws/service/actions/DestroyJob.java @@ -16,7 +16,7 @@ package uws.service.actions; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -43,7 +43,7 @@ import uws.service.log.UWSLog.LogLevel; * The response of this action is a redirection to the jobs list.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (11/2014) + * @version 4.1 (04/2015) */ public class DestroyJob extends UWSAction { private static final long serialVersionUID = 1L; diff --git a/src/uws/service/actions/GetJobParam.java b/src/uws/service/actions/GetJobParam.java index c82988774bb39007bb71b79f2c3feb480642b373..37b23ba3dca5b701c1846be957928bf736a1db43 100644 --- a/src/uws/service/actions/GetJobParam.java +++ b/src/uws/service/actions/GetJobParam.java @@ -16,7 +16,7 @@ package uws.service.actions; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -50,7 +50,7 @@ import uws.service.request.UploadFile; * The serializer is choosen in function of the HTTP Accept header.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (09/2014) + * @version 4.1 (04/2015) */ public class GetJobParam extends UWSAction { private static final long serialVersionUID = 1L; @@ -171,11 +171,16 @@ public class GetJobParam extends UWSAction { UWSSerializer serializer = uws.getSerializer(request.getHeader("Accept")); String uwsField = attributes[0]; boolean jobSerialization = false; + // Set the content type: if (uwsField == null || uwsField.trim().isEmpty() || (attributes.length <= 1 && (uwsField.equalsIgnoreCase(UWSJob.PARAM_ERROR_SUMMARY) || uwsField.equalsIgnoreCase(UWSJob.PARAM_RESULTS) || uwsField.equalsIgnoreCase(UWSJob.PARAM_PARAMETERS)))){ response.setContentType(serializer.getMimeType()); jobSerialization = true; }else response.setContentType("text/plain"); + + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + // Serialize the selected attribute: try{ job.serialize(response.getOutputStream(), attributes, serializer); }catch(Exception e){ diff --git a/src/uws/service/actions/JobSummary.java b/src/uws/service/actions/JobSummary.java index d645259e9d7eb06e8c5c29aa6e69484893ce1337..e6cdee274d2c11342be53a5c279a2034c7c1cd21 100644 --- a/src/uws/service/actions/JobSummary.java +++ b/src/uws/service/actions/JobSummary.java @@ -16,7 +16,7 @@ package uws.service.actions; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import uws.UWSException; +import uws.UWSToolBox; import uws.job.UWSJob; import uws.job.serializer.UWSSerializer; import uws.job.user.JobOwner; @@ -43,7 +44,7 @@ import uws.service.log.UWSLog.LogLevel; * This summary is serialized by the {@link UWSSerializer} choosed in function of the HTTP Accept header.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (08/2014) + * @version 4.1 (04/2015) */ public class JobSummary extends UWSAction { private static final long serialVersionUID = 1L; @@ -100,6 +101,7 @@ public class JobSummary extends UWSAction { // Write the job summary: UWSSerializer serializer = uws.getSerializer(request.getHeader("Accept")); response.setContentType(serializer.getMimeType()); + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); try{ job.serialize(response.getOutputStream(), serializer, user); }catch(Exception e){ diff --git a/src/uws/service/actions/ListJobs.java b/src/uws/service/actions/ListJobs.java index 18be0642f222c41dab5e461bf8e5b4fd23852d55..83a7a711396d00b092058afe3795c3b19adda479 100644 --- a/src/uws/service/actions/ListJobs.java +++ b/src/uws/service/actions/ListJobs.java @@ -16,7 +16,7 @@ package uws.service.actions; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import uws.UWSException; +import uws.UWSToolBox; import uws.job.JobList; import uws.job.serializer.UWSSerializer; import uws.job.user.JobOwner; @@ -43,7 +44,7 @@ import uws.service.log.UWSLog.LogLevel; * This list is serialized by the {@link UWSSerializer} choosed in function of the HTTP Accept header.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (08/2014) + * @version 4.1 (04/2015) */ public class ListJobs extends UWSAction { private static final long serialVersionUID = 1L; @@ -99,6 +100,7 @@ public class ListJobs extends UWSAction { // Write the jobs list: UWSSerializer serializer = uws.getSerializer(request.getHeader("Accept")); response.setContentType(serializer.getMimeType()); + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); try{ jobsList.serialize(response.getOutputStream(), serializer, user); }catch(Exception e){ diff --git a/src/uws/service/actions/SetJobParam.java b/src/uws/service/actions/SetJobParam.java index d9f18821609dfde289c33cbf008b3e35d95f8c45..df6788703aee79b2b0f9ed6285bb40f1ff858423 100644 --- a/src/uws/service/actions/SetJobParam.java +++ b/src/uws/service/actions/SetJobParam.java @@ -16,7 +16,7 @@ package uws.service.actions; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -43,7 +43,7 @@ import uws.service.log.UWSLog.LogLevel; * The response of this action is a redirection to the job summary.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 4.1 (09/2014) + * @version 4.1 (04/2015) */ public class SetJobParam extends UWSAction { private static final long serialVersionUID = 1L; diff --git a/src/uws/service/actions/SetUWSParameter.java b/src/uws/service/actions/SetUWSParameter.java index dab912fd6b6e90994d2d3eb94b3cedc1d703a999..832823af772db08306e5a001e53196561a544924 100644 --- a/src/uws/service/actions/SetUWSParameter.java +++ b/src/uws/service/actions/SetUWSParameter.java @@ -16,7 +16,7 @@ package uws.service.actions; * You should have received a copy of the GNU Lesser General Public License * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2014 - Astronomisches Rechen Institut (ARI) + * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI) */ import java.io.IOException; @@ -40,7 +40,7 @@ import uws.service.UWSUrl; * <p><i><u>Note:</u> The corresponding name is {@link UWSAction#SET_UWS_PARAMETER}.</i></p> * * @author Grégory Mantelet (ARI) - * @version 4.1 (11/2014) + * @version 4.1 (04/2015) * @since 4.1 */ public class SetUWSParameter extends UWSAction { diff --git a/src/uws/service/actions/ShowHomePage.java b/src/uws/service/actions/ShowHomePage.java index 7d4205d7dcb8f85201ef03e9aa06dd74dab330ea..bba81ebfcfcece598aac1095733c1bdeba2c5b0b 100644 --- a/src/uws/service/actions/ShowHomePage.java +++ b/src/uws/service/actions/ShowHomePage.java @@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import uws.UWSException; +import uws.UWSToolBox; import uws.job.serializer.UWSSerializer; import uws.job.user.JobOwner; import uws.service.UWSService; @@ -100,6 +101,7 @@ public class ShowHomePage extends UWSAction { if (uws.isDefaultHomePage()){ UWSSerializer serializer = uws.getSerializer(request.getHeader("Accept")); response.setContentType(serializer.getMimeType()); + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); // Get a short and simple serialization of this UWS: String serialization; try{ @@ -127,6 +129,7 @@ public class ShowHomePage extends UWSAction { BufferedReader reader = new BufferedReader(new InputStreamReader(homePageUrl.openStream())); response.setContentType("text/html"); + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); PrintWriter writer = response.getWriter(); try{ String line = null; diff --git a/src/uws/service/error/DefaultUWSErrorWriter.java b/src/uws/service/error/DefaultUWSErrorWriter.java index 90196133a67a3341ac49b4f50602309b01beb846..345d1c26b5933c6d1c5c9b06166445a02712c86d 100644 --- a/src/uws/service/error/DefaultUWSErrorWriter.java +++ b/src/uws/service/error/DefaultUWSErrorWriter.java @@ -212,6 +212,9 @@ public class DefaultUWSErrorWriter implements ServiceErrorWriter { // Set the MIME type of the answer (XML for a VOTable document): response.setContentType(UWSSerializer.MIME_TYPE_HTML); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + }catch(IllegalStateException ise){ /* If it is not possible any more to reset the response header and body, * the error is anyway written in order to corrupt the HTTP response. @@ -292,6 +295,9 @@ public class DefaultUWSErrorWriter implements ServiceErrorWriter { // Set the MIME type of the answer (JSON): response.setContentType(UWSSerializer.MIME_TYPE_JSON); + // Set the character encoding: + response.setCharacterEncoding(UWSToolBox.DEFAULT_CHAR_ENCODING); + }catch(IllegalStateException ise){ /* If it is not possible any more to reset the response header and body, * the error is anyway written in order to corrupt the HTTP response.