[JENKINS-13536] I think the proper thing to do is to use the Accept header, not the Content-Type header.

This commit is contained in:
Kohsuke Kawaguchi committed 2012-04-25 23:58:54 -07:00
1 parent 1409fdff19
commit c12df414ea
1 file changed
+7 -1
@@ -148,7 +148,7 @@ public class ParametersDefinitionProperty extends JobProperty<AbstractProject<?,
Jenkins.getInstance().getQueue().schedule(
owner, owner.getDelay(req), new ParametersAction(values), owner.getBuildCause(req));
if (req.getContentType() != null && req.getContentType().contains("application/json")) {
if (requestWantsJson(req)) {
rsp.setContentType("application/json");
rsp.serveExposedBean(req, owner, Flavor.JSON);
} else {
@@ -157,6 +157,12 @@ public class ParametersDefinitionProperty extends JobProperty<AbstractProject<?,
}
}
private boolean requestWantsJson(StaplerRequest req) {
String a = req.getHeader("Accept");
if (a==null) return false;
return !a.contains("text/html") && a.contains("application/json");
}
/**
* Gets the {@link ParameterDefinition} of the given name, if any.
*/