Skip to content

Commit

Permalink
ensure null header values are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed May 30, 2024
1 parent 1708454 commit 2ba55dc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/io/cryostat/agent/MainModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -162,7 +163,10 @@ public static HttpClient provideHttpClient(
@Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_CONNECT_TIMEOUT_MS) int connectTimeout,
@Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_RESPONSE_TIMEOUT_MS) int responseTimeout) {
Set<Header> headers = new HashSet<>();
authorization.map(v -> new BasicHeader("Authorization", v)).ifPresent(headers::add);
authorization
.filter(Objects::nonNull)
.map(v -> new BasicHeader("Authorization", v))
.ifPresent(headers::add);
HttpClientBuilder builder =
HttpClients.custom()
.setDefaultHeaders(headers)
Expand Down

0 comments on commit 2ba55dc

Please sign in to comment.