Skip to content

Commit

Permalink
refactor: do not send cookie if not available
Browse files Browse the repository at this point in the history
This avoids passing empty cookie in requestq
  • Loading branch information
tbouffard committed Oct 10, 2019
1 parent c4eebf2 commit 9d991e2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.cdancy.jenkins.rest.filters;

import java.util.Optional;
import javax.inject.Inject;
import javax.inject.Singleton;

Expand Down Expand Up @@ -61,7 +62,8 @@ public HttpRequest filter(final HttpRequest request) throws HttpException {
final Pair<Crumb, Boolean> localCrumb = getCrumb();
if (localCrumb.getKey().value() != null) {
builder.addHeader(CRUMB_HEADER, localCrumb.getKey().value());
builder.addHeader(HttpHeaders.COOKIE, localCrumb.getKey().sessionIdCookie());
Optional.ofNullable(localCrumb.getKey().sessionIdCookie())
.ifPresent(sessionId -> builder.addHeader(sessionId));
} else {
if (localCrumb.getValue() == false) {
throw new RuntimeException("Unexpected exception being thrown: error=" + localCrumb.getKey().errors().get(0));
Expand Down

0 comments on commit 9d991e2

Please sign in to comment.