mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 11348: make content type for "json" files configurable
status 11348: resolved fixed
This commit is contained in:
parent
ba2c6695cc
commit
b883b25a12
@ -120,6 +120,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
public static final short RESOURCE_DOMAIN_ADMIN_COMMAND = 2;
|
||||
public static final short USER_COMMAND = 8;
|
||||
public static boolean encodeApiResponse = false;
|
||||
public static String jsonContentType = "text/javascript";
|
||||
private Properties _apiCommands = null;
|
||||
private ApiDispatcher _dispatcher;
|
||||
private ManagementServer _ms = null;
|
||||
@ -233,6 +234,11 @@ public class ApiServer implements HttpRequestHandler {
|
||||
}
|
||||
|
||||
encodeApiResponse = Boolean.valueOf(configDao.getValue(Config.EncodeApiResponse.key()));
|
||||
|
||||
String jsonType = configDao.getValue(Config.JavaScriptDefaultContentType.key());
|
||||
if (jsonType != null) {
|
||||
jsonContentType = jsonType;
|
||||
}
|
||||
|
||||
ListenerThread listenerThread = new ListenerThread(this, apiPort);
|
||||
listenerThread.start();
|
||||
@ -773,7 +779,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
BasicHttpEntity body = new BasicHttpEntity();
|
||||
if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
// JSON response
|
||||
body.setContentType("text/javascript");
|
||||
body.setContentType(jsonContentType);
|
||||
if (responseText == null) {
|
||||
body.setContent(new ByteArrayInputStream("{ \"error\" : { \"description\" : \"Internal Server Error\" } }".getBytes("UTF-8")));
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ public class ApiServlet extends HttpServlet {
|
||||
private void writeResponse(HttpServletResponse resp, String response, int responseCode, String responseType) {
|
||||
try {
|
||||
if (BaseCmd.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
resp.setContentType("text/javascript; charset=UTF-8");
|
||||
resp.setContentType(ApiServer.jsonContentType + "; charset=UTF-8");
|
||||
} else {
|
||||
resp.setContentType("text/xml; charset=UTF-8");
|
||||
}
|
||||
|
||||
@ -273,7 +273,9 @@ public enum Config {
|
||||
DnsBasicZoneUpdates("Advanced", NetworkManager.class, String.class, "network.dns.basiczone.updates", "all", "This parameter can take 2 values: all (default) and pod. It defines if DHCP/DNS requests have to be send to all dhcp servers in cloudstack, or only to the one in the same pod", "all,pod"),
|
||||
|
||||
ClusterMessageTimeOutSeconds("Advanced", ManagementServer.class, Integer.class, "cluster.message.timeout.seconds", "300", "Time (in seconds) to wait before a inter-management server message post times out.", null),
|
||||
AgentLoadThreshold("Advanced", ManagementServer.class, Float.class, "agent.load.threshold", "0.7", "Percentage (as a value between 0 and 1) of connected agents after which agent load balancing will start happening", null);
|
||||
AgentLoadThreshold("Advanced", ManagementServer.class, Float.class, "agent.load.threshold", "0.7", "Percentage (as a value between 0 and 1) of connected agents after which agent load balancing will start happening", null),
|
||||
|
||||
JavaScriptDefaultContentType("Advanced", ManagementServer.class, String.class, "json.content.type", "text/javascript", "Http response content type for .js files (default is text/javascript)", null);
|
||||
|
||||
private final String _category;
|
||||
private final Class<?> _componentClass;
|
||||
|
||||
@ -6,3 +6,5 @@ ALTER TABLE `cloud`.`vm_template` ADD COLUMN `template_tag` varchar(255) COMMENT
|
||||
|
||||
UPDATE vm_instance SET state='Error' WHERE state='Creating' AND removed IS null;
|
||||
|
||||
INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'json.content.type', 'text/javascript', 'Http response content type for .js files (default is text/javascript)');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user