(TK-23) Cleanups based on PR feedback

This commit is contained in:
Chris Price 2014-07-03 09:21:42 -07:00
parent 186b226512
commit 729af72491
3 changed files with 4 additions and 14 deletions

View file

@ -68,18 +68,13 @@
[opts :- schemas/SslOptions]
(cond
(:ssl-context opts) opts
(every? (partial opts) [:ssl-cert :ssl-key :ssl-ca-cert]) (configure-ssl-from-pems opts)
(every? opts [:ssl-cert :ssl-key :ssl-ca-cert]) (configure-ssl-from-pems opts)
(:ssl-ca-cert opts) (configure-ssl-from-ca-pem opts)
:else opts))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Private utility functions
(defn- check-url!
[url]
(when (nil? url)
(throw (IllegalArgumentException. "Host URL cannot be nil"))))
(defn- add-accept-encoding-header
[decompress-body? headers]
(if (and decompress-body?
@ -277,7 +272,6 @@
(request opts nil))
([opts :- schemas/RawUserRequestOptions
callback :- schemas/ResponseCallbackFn]
(check-url! (:url opts))
(let [defaults {:headers {}
:body nil
:decompress-body true

View file

@ -9,11 +9,6 @@ import org.slf4j.LoggerFactory;
public class AsyncHttpClient {
private static final Logger LOGGER = LoggerFactory.getLogger(SyncHttpClient.class);
private static void logAndRethrow(String msg, Throwable t) {
LOGGER.error(msg, t);
throw new HttpClientException(msg, t);
}
public static Promise<Response> request(RequestOptions options) {
options = SslUtils.configureSsl(options);

View file

@ -10,7 +10,8 @@
[puppetlabs.trapperkeeper.testutils.logging :as testlogging]
[puppetlabs.trapperkeeper.services.webserver.jetty9-service :as jetty9]
[puppetlabs.http.client.sync :as sync]
[schema.test :as schema-test]))
[schema.test :as schema-test]
[clojure.java.io :as io]))
(use-fixtures :once schema-test/validate-schemas)
@ -178,7 +179,7 @@
(is (= 200 (.getStatus response)))
(is (= "foo" (slurp (.getBody response))))))
(testing "clojure sync client: string body for post request"
(let [response (sync/post "http://localhost:10000/hello/" {:body (ByteArrayInputStream. (.getBytes "foo" "UTF-8"))})]
(let [response (sync/post "http://localhost:10000/hello/" {:body (io/input-stream (.getBytes "foo" "UTF-8"))})]
(is (= 200 (:status response)))
(is (= "foo" (slurp (:body response)))))))))