Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #97 from jtnord/JENKINS-50590
[JENKINS-50590] do not remove all request parameters when adding a crumb
- Loading branch information
Showing
with
11 additions
and
4 deletions.
-
+11
−4
src/main/java/org/jvnet/hudson/test/JenkinsRule.java
|
@@ -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(); |
|
|
req.setRequestParameters(Arrays.asList(crumb)); |
|
|
ArrayList<NameValuePair> params = new ArrayList<>(); |
|
|
params.add(getCrumbHeaderNVP()); |
|
|
List<NameValuePair> oldParams = req.getRequestParameters(); |
|
|
if (oldParams != null) { |
|
|
params.addAll(oldParams); |
|
|
} |
|
|
req.setRequestParameters(params); |
|
|
return req; |
|
|
} |
|
|
|
|
@@ -2312,8 +2317,10 @@ public URL createCrumbedUrl(String relativePath) throws IOException { |
|
|
CrumbIssuer issuer = jenkins.getCrumbIssuer(); |
|
|
String crumbName = issuer.getDescriptor().getCrumbRequestField(); |
|
|
String crumb = issuer.getCrumb(null); |
|
|
|
|
|
return new URL(getContextPath()+relativePath+"?"+crumbName+"="+crumb); |
|
|
if (relativePath.indexOf('?') == -1) { |
|
|
return new URL(getContextPath()+relativePath+"?"+crumbName+"="+crumb); |
|
|
} |
|
|
return new URL(getContextPath()+relativePath+"&"+crumbName+"="+crumb); |
|
|
} |
|
|
|
|
|
/** |
|
|