mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
[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:
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.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user