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

[FIXED JENKINS-18425]

"201 Created" response doesn't work well with a browser as the user agent.
上级 c7c05f6a
......@@ -55,6 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
Build with parameters returns empty web page
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18425">issue 18425</a>)
<li class=bug>
Access denied error results in ERR_CONTENT_DECODING_FAILED on most browsers, masking the root cause.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15437">issue 15437</a>)
......
......@@ -34,6 +34,7 @@ import java.util.AbstractList;
import javax.servlet.ServletException;
import hudson.Util;
import hudson.model.Queue.WaitingItem;
import jenkins.model.Jenkins;
import jenkins.util.TimeDuration;
......@@ -140,9 +141,12 @@ public class ParametersDefinitionProperty extends JobProperty<AbstractProject<?,
WaitingItem item = Jenkins.getInstance().getQueue().schedule(
owner, delay.getTime(), new ParametersAction(values), new CauseAction(new Cause.UserIdCause()));
if (item!=null)
rsp.sendRedirect(SC_CREATED,req.getContextPath()+'/'+item.getUrl());
else
if (item!=null) {
String url = formData.optString("redirectTo");
if (url==null || Util.isAbsoluteUri(url)) // avoid open redirect
url = req.getContextPath()+'/'+item.getUrl();
rsp.sendRedirect(formData.optInt("statusCode",SC_CREATED), url);
} else
// send the user back to the job top page.
rsp.sendRedirect(".");
}
......
......@@ -51,6 +51,17 @@ THE SOFTWARE.
</tbody>
</j:forEach>
<f:block>
<!--
When used from the UI, use 303 redirect and send back to the job top page.
When neither of those options are given, we'll report "201 Created".
We can't use XHR for submitting this as there might be file parameters,
and submitting to IFRAME won't work either because 201 can't have HTML response.
So I think all we can do is this somewhat clunky workaround.
-->
<input type="hidden" name="statusCode" value="303" />
<input type="hidden" name="redirectTo" value="." />
<f:submit value="${%Build}" />
</f:block>
</f:form>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册