(TK-108) Address PR comments
Remove the client option from SimpleRequestOptions and RequestOptions as it was not being used. Correct initialization of the Logger in various classes to use the correct class.
This commit is contained in:
parent
ff76e719b3
commit
a6fb04697e
8 changed files with 6 additions and 40 deletions
|
@ -12,7 +12,7 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
|
||||
public class Async {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Sync.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Async.class);
|
||||
|
||||
private static Promise<Response> request(SimpleRequestOptions requestOptions) {
|
||||
return JavaClient.request(requestOptions, null);
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
package com.puppetlabs.http.client;
|
||||
|
||||
import org.apache.http.nio.client.HttpAsyncClient;
|
||||
//import org.httpkit.client.HttpClient;
|
||||
//
|
||||
//import org.httpkit.client.IFilter;
|
||||
//import org.httpkit.client.MultipartEntity;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
public class RequestOptions {
|
||||
private HttpAsyncClient client = null;
|
||||
|
||||
private URI uri;
|
||||
private HttpMethod method = null;
|
||||
private Map<String, String> headers;
|
||||
|
@ -25,14 +16,12 @@ public class RequestOptions {
|
|||
public RequestOptions(URI uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
public RequestOptions (HttpAsyncClient client,
|
||||
URI uri,
|
||||
public RequestOptions (URI uri,
|
||||
HttpMethod method,
|
||||
Map<String, String> headers,
|
||||
Object body,
|
||||
boolean decompressBody,
|
||||
ResponseBodyType as) {
|
||||
this.client = client;
|
||||
this.uri = uri;
|
||||
this.method = method;
|
||||
this.headers = headers;
|
||||
|
@ -41,14 +30,6 @@ public class RequestOptions {
|
|||
this.as = as;
|
||||
}
|
||||
|
||||
public HttpAsyncClient getClient() {
|
||||
return client;
|
||||
}
|
||||
public RequestOptions setClient(HttpAsyncClient client) {
|
||||
this.client = client;
|
||||
return this;
|
||||
}
|
||||
|
||||
public URI getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package com.puppetlabs.http.client;
|
||||
|
||||
import org.apache.http.nio.client.HttpAsyncClient;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
public class SimpleRequestOptions {
|
||||
private HttpAsyncClient client = null;
|
||||
|
||||
private URI uri;
|
||||
private HttpMethod method = null;
|
||||
private Map<String, String> headers;
|
||||
|
@ -31,14 +27,6 @@ public class SimpleRequestOptions {
|
|||
this.uri = uri;
|
||||
}
|
||||
|
||||
public HttpAsyncClient getClient() {
|
||||
return client;
|
||||
}
|
||||
public SimpleRequestOptions setClient(HttpAsyncClient client) {
|
||||
this.client = client;
|
||||
return this;
|
||||
}
|
||||
|
||||
public URI getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@ public class Sync {
|
|||
// we should refactor this implementation so that it is based on the
|
||||
// async one, as Patrick has done in the clojure API.
|
||||
|
||||
//clientOptions = SslUtils.configureSsl(clientOptions);
|
||||
|
||||
Promise<Response> promise = JavaClient.request(requestOptions, null);
|
||||
|
||||
Response response = null;
|
||||
|
|
|
@ -395,14 +395,13 @@ public class JavaClient {
|
|||
}
|
||||
|
||||
private static RequestOptions extractRequestOptions(SimpleRequestOptions simpleOptions) {
|
||||
HttpAsyncClient client = simpleOptions.getClient();
|
||||
URI uri = simpleOptions.getUri();
|
||||
HttpMethod method = simpleOptions.getMethod();
|
||||
Map<String, String> headers = simpleOptions.getHeaders();
|
||||
Object body = simpleOptions.getBody();
|
||||
boolean decompressBody = simpleOptions.getDecompressBody();
|
||||
ResponseBodyType as = simpleOptions.getAs();
|
||||
return new RequestOptions(client, uri, method, headers, body, decompressBody, as);
|
||||
return new RequestOptions(uri, method, headers, body, decompressBody, as);
|
||||
}
|
||||
|
||||
private static ClientOptions extractClientOptions(SimpleRequestOptions simpleOptions) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.net.URISyntaxException;
|
|||
|
||||
public class PersistentAsyncHttpClient implements AsyncHttpClient {
|
||||
private CloseableHttpAsyncClient client;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Sync.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PersistentAsyncHttpClient.class);
|
||||
|
||||
public PersistentAsyncHttpClient(CloseableHttpAsyncClient client) {
|
||||
this.client = client;
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.net.URISyntaxException;
|
|||
|
||||
public class PersistentSyncHttpClient implements SyncHttpClient {
|
||||
private CloseableHttpAsyncClient client;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Sync.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PersistentSyncHttpClient.class);
|
||||
|
||||
public PersistentSyncHttpClient(CloseableHttpAsyncClient client) {
|
||||
this.client = client;
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.security.UnrecoverableKeyException;
|
|||
import java.security.cert.CertificateException;
|
||||
|
||||
public class SslUtils {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Sync.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SslUtils.class);
|
||||
|
||||
private static void logAndRethrow(String msg, Throwable t) {
|
||||
LOGGER.error(msg, t);
|
||||
|
|
Loading…
Reference in a new issue