aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-02-08 14:16:15 -0500
committerJim Hahn <jrh3@att.com>2020-02-08 14:23:28 -0500
commit1b73b599b23921b3412d60ed231de1ef8ac90dbb (patch)
treebffa64e21761c8e27ae46dd0678037cc55dbeec2 /policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
parent277c904618294d9a18d8c2b852f31666c996f810 (diff)
Add headers to asynchronous get in HttpClient
Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I61ef2fcfde5eb361652d2d6e3f55324af7ca7b4e
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
index 1a822ff2..38ec6829 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
@@ -26,6 +26,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
+import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Future;
@@ -171,17 +172,23 @@ public class JerseyClient implements HttpClient {
}
@Override
- public Future<Response> get(InvocationCallback<Response> callback, String path) {
+ public Future<Response> get(InvocationCallback<Response> callback, String path, Map<String, Object> headers) {
+ Map<String, Object> headers2 = (headers != null ? headers : Collections.emptyMap());
+
if (!StringUtils.isBlank(path)) {
- return this.client.target(this.baseUrl).path(path).request().async().get(callback);
+ return getBuilder(path, headers2).async().get(callback);
} else {
- return this.client.target(this.baseUrl).request().async().get(callback);
+ return get(callback, headers2);
}
}
@Override
- public Future<Response> get(InvocationCallback<Response> callback) {
- return this.client.target(this.baseUrl).request().async().get(callback);
+ public Future<Response> get(InvocationCallback<Response> callback, Map<String, Object> headers) {
+ Builder builder = this.client.target(this.baseUrl).request();
+ if (headers != null) {
+ headers.forEach(builder::header);
+ }
+ return builder.async().get(callback);
}
@Override