提交 c12df414 编写于 作者: K Kohsuke Kawaguchi

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

[JENKINS-13536] I think the proper thing to do is to use the Accept header, not the Content-Type header.
上级 1409fdff
......@@ -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.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册