diff --git a/src/main/java/com/smartystreets/api/ClientBuilder.java b/src/main/java/com/smartystreets/api/ClientBuilder.java index 173d29b..bb6460f 100644 --- a/src/main/java/com/smartystreets/api/ClientBuilder.java +++ b/src/main/java/com/smartystreets/api/ClientBuilder.java @@ -17,7 +17,7 @@ public class ClientBuilder { private int maxTimeout; private String urlPrefix; private Proxy proxy; - private Map customHeaders; + private Map customHeaders; private final String INTERNATIONAL_STREET_API_URL = "https://international-street.api.smartystreets.com/verify"; private final String US_AUTOCOMPLETE_API_URL = "https://us-autocomplete.api.smartystreets.com/suggest"; private final String US_EXTRACT_API_URL = "https://us-extract.api.smartystreets.com/"; @@ -89,10 +89,10 @@ public ClientBuilder withCustomBaseUrl(String baseUrl) { /** * Use this to add any additional headers you need. - * @param customHeaders A string to string Map of header name/value pairs. + * @param customHeaders A String to Object Map of header name/value pairs. * @return Returns this to accommodate method chaining. */ - public ClientBuilder withCustomHeaders(Map customHeaders) { + public ClientBuilder withCustomHeaders(Map customHeaders) { this.customHeaders = customHeaders; return this; } diff --git a/src/main/java/com/smartystreets/api/CustomHeaderSender.java b/src/main/java/com/smartystreets/api/CustomHeaderSender.java index 8f1f4ff..d493c97 100644 --- a/src/main/java/com/smartystreets/api/CustomHeaderSender.java +++ b/src/main/java/com/smartystreets/api/CustomHeaderSender.java @@ -6,20 +6,18 @@ import java.util.Map; public class CustomHeaderSender implements Sender { - private Map headers; + private Map headers; private Sender inner; - public CustomHeaderSender(Map headers, Sender inner){ + public CustomHeaderSender(Map headers, Sender inner){ this.headers = headers; this.inner = inner; } @Override public Response send(Request request) throws SmartyException, IOException { - Map requestHeaders = request.getHeaders(); - for (Map.Entry entry : this.headers.entrySet()) { - request.putHeader((String)entry.getKey(), (String)entry.getValue()); + request.putHeader((String)entry.getKey(), entry.getValue()); } return this.inner.send(request); diff --git a/src/main/java/com/smartystreets/api/GoogleSender.java b/src/main/java/com/smartystreets/api/GoogleSender.java index 7975d3e..c1722e4 100644 --- a/src/main/java/com/smartystreets/api/GoogleSender.java +++ b/src/main/java/com/smartystreets/api/GoogleSender.java @@ -65,7 +65,7 @@ private HttpRequest buildHttpRequest(Request smartyRequest) throws IOException { private void copyHeaders(Request smartyRequest, HttpRequest httpRequest) { HttpHeaders httpHeaders = httpRequest.getHeaders(); - Map headers = smartyRequest.getHeaders(); + Map headers = smartyRequest.getHeaders(); for (String headerName : headers.keySet()) httpHeaders.set(headerName, headers.get(headerName)); diff --git a/src/main/java/com/smartystreets/api/Request.java b/src/main/java/com/smartystreets/api/Request.java index f84b446..42ebab0 100644 --- a/src/main/java/com/smartystreets/api/Request.java +++ b/src/main/java/com/smartystreets/api/Request.java @@ -7,7 +7,7 @@ public class Request { private static final String CHARSET = "UTF-8"; - private final Map headers; + private final Map headers; private final Map parameters; private String urlPrefix; private String method; @@ -22,7 +22,7 @@ public Request() { this.contentType = "application/json"; } - void putHeader(String name, String value) { + void putHeader(String name, Object value) { this.headers.put(name, value); } @@ -65,7 +65,7 @@ public String getMethod() { return method; } - public Map getHeaders() { + public Map getHeaders() { return this.headers; } diff --git a/src/test/java/com/smartystreets/api/CustomHeaderSenderTest.java b/src/test/java/com/smartystreets/api/CustomHeaderSenderTest.java index 39e9117..5350dd6 100644 --- a/src/test/java/com/smartystreets/api/CustomHeaderSenderTest.java +++ b/src/test/java/com/smartystreets/api/CustomHeaderSenderTest.java @@ -14,7 +14,7 @@ public class CustomHeaderSenderTest { @Test public void testAllCustomHeadersAreAddedToTheRequest() throws IOException, SmartyException { - HashMap headers = new HashMap<>(); + HashMap headers = new HashMap<>(); headers.put("A", "1"); headers.put("B", "2"); RequestCapturingSender inner = new RequestCapturingSender(); @@ -23,7 +23,7 @@ public void testAllCustomHeadersAreAddedToTheRequest() throws IOException, Smart sender.send(request); - Map requestHeaders = inner.getRequest().getHeaders(); + Map requestHeaders = inner.getRequest().getHeaders(); assertNotNull("There should be headers here.", requestHeaders); assertEquals(headers.get("A"), inner.getRequest().getHeaders().get("A")); diff --git a/src/test/java/com/smartystreets/api/GoogleSenderTest.java b/src/test/java/com/smartystreets/api/GoogleSenderTest.java index 1a1c489..e696ae4 100644 --- a/src/test/java/com/smartystreets/api/GoogleSenderTest.java +++ b/src/test/java/com/smartystreets/api/GoogleSenderTest.java @@ -29,7 +29,7 @@ public void testHttpRequestContainsCorrectHeaders() throws Exception { sender.send(request); - Map headers = request.getHeaders(); + Map headers = request.getHeaders(); assertEquals("value1", headers.get("X-name1")); assertEquals("value2", headers.get("X-name2")); }