Skip to content
Browse files

[JENKINS-50590] do not remove all request parameters when adding a crumb

If you had a WebRequest with existing Parameters specified then adding a
crumb would remove all of those headers.  THis is somewhat suprising.

I thought about making getCrumbHeaderNVP() public but went with the
option that should anyway cause the least suprise.  The crumb is now
added to the list of parameters rather than replacing them.  It is added
first such that if there where existing crumb fields the newly added one
should be first.
  • Loading branch information
jtnord committed Apr 5, 2018
1 parent 618723e commit 4821d0fe49f37d699a5ca294f0719f3287839eef
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/main/java/org/jvnet/hudson/test/
@@ -2300,8 +2300,13 @@ public String getContextPath() throws IOException {
* Use {@link #createCrumbedUrl} instead if you intend to call {@link WebRequest#setRequestBody}, typical of a POST request.
public WebRequest addCrumb(WebRequest req) {
NameValuePair crumb = getCrumbHeaderNVP();
ArrayList<NameValuePair> params = new ArrayList<>();
List<NameValuePair> oldParams = req.getRequestParameters();
if (oldParams != null && !oldParams.isEmpty()) {
return req;

0 comments on commit 4821d0f

Please sign in to comment.