aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/main/java/org')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java17
2 files changed, 17 insertions, 8 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
index ebed1d7e..9e4e412f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
@@ -53,19 +53,21 @@ public interface HttpClient extends Startable {
* Asynchronous GET request.
*
* @param callback callback to be invoked, asynchronously, when the request completes
- * @param path context uri path.
+ * @param path context uri path
+ * @param headers request headers
*
* @return future that can be used to cancel the request or await the response
*/
- Future<Response> get(InvocationCallback<Response> callback, String path);
+ Future<Response> get(InvocationCallback<Response> callback, String path, Map<String, Object> headers);
/**
* Asynchronous GET request.
*
* @param callback callback to be invoked, asynchronously, when the request completes
+ * @param headers request headers
* @return future that can be used to cancel the request or await the response
*/
- Future<Response> get(InvocationCallback<Response> callback);
+ Future<Response> get(InvocationCallback<Response> callback, Map<String, Object> headers);
/**
* PUT request.
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