Commit 8d630a59 authored by gmantele's avatar gmantele
Browse files

[UWS,TAP] Set UTF-8 as default character encoding for all HTTP response.

parent 998d11f5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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());
+4 −0
Original line number Diff line number Diff line
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -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);
+6 −2
Original line number Diff line number Diff line
@@ -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&eacute;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();

+5 −1
Original line number Diff line number Diff line
@@ -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&eacute;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();

Loading