Merge pull request #375 from coheigea/AMQ-7242

AMQ-7242 - REST Content Type fixes
This commit is contained in:
Jean-Baptiste Onofré 2019-07-26 11:20:47 +02:00 committed by GitHub
commit a342490931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -66,7 +66,7 @@ public class MessageServlet extends MessageServletSupport {
private long defaultReadTimeout = -1;
private long maximumReadTimeout = 20000;
private long requestTimeout = 1000;
private String defaultContentType = "application/xml";
private String defaultContentType;
private final HashMap<String, WebClient> clients = new HashMap<String, WebClient>();
private final HashSet<MessageAvailableConsumer> activeConsumers = new HashSet<MessageAvailableConsumer>();
@ -285,15 +285,16 @@ public class MessageServlet extends MessageServletSupport {
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0);
// Set content type as in request. This should be done before calling getWriter by specification
String type = request.getContentType();
String type = getContentType(request);
if (type != null) {
response.setContentType(type);
} else {
if (isXmlContent(message)) {
if (defaultContentType != null) {
response.setContentType(defaultContentType);
} else if (isXmlContent(message)) {
response.setContentType("application/xml");
} else {
response.setContentType("text/plain");
}