Skip to content

Commit aab51ad

Browse files
ravilaudyajoelittlejohn
authored andcommitted
Support for protocol in client options
Closes #157
1 parent 7d79f24 commit aab51ad

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/taoensso/faraday.clj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
Get]
108108

109109
com.amazonaws.ClientConfiguration
110+
com.amazonaws.Protocol
110111
com.amazonaws.auth.AWSCredentials
111112
com.amazonaws.auth.AWSCredentialsProvider
112113
com.amazonaws.auth.BasicAWSCredentials
@@ -132,8 +133,8 @@
132133
(defn- client-params
133134
[{:as client-opts
134135
:keys [provider creds access-key secret-key proxy-host proxy-port
135-
proxy-username proxy-password
136-
conn-timeout max-conns max-error-retry socket-timeout keep-alive?]}]
136+
proxy-username proxy-password conn-timeout max-conns
137+
max-error-retry socket-timeout keep-alive? protocol]}]
137138

138139
(let [creds (or creds (:credentials client-opts)) ; Deprecated opt
139140

@@ -148,6 +149,7 @@
148149

149150
^AWSCredentialsProvider provider
150151
(or provider (when-not aws-creds (DefaultAWSCredentialsProviderChain.)))
152+
proto (Protocol/valueOf (name (or protocol :HTTPS)))
151153

152154
client-config
153155
(doto-cond [g (ClientConfiguration.)]
@@ -159,7 +161,8 @@
159161
max-conns (.setMaxConnections g)
160162
max-error-retry (.setMaxErrorRetry g)
161163
socket-timeout (.setSocketTimeout g)
162-
keep-alive? (.setUseTcpKeepAlive g))]
164+
keep-alive? (.setUseTcpKeepAlive g)
165+
proto (.setProtocol g))]
163166

164167
[aws-creds provider client-config]))
165168

test/taoensso/faraday/tests/main.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@
7070

7171
(deftest client-creation
7272
(is (#'far/db-client (assoc *client-opts* :region "us-east-1")))
73-
(is (#'far/db-client (assoc *client-opts* :endpoint "http://localhost:6798"))))
73+
(is (#'far/db-client (assoc *client-opts* :endpoint "http://localhost:6798")))
74+
(is (#'far/db-client (assoc *client-opts* :protocol "HTTP")))
75+
(is (#'far/db-client (assoc *client-opts* :protocol "HTTPS")))
76+
(is (thrown? IllegalArgumentException
77+
(#'far/db-client (assoc *client-opts* :protocol "random")))))
7478

7579
(deftest basic-api
7680
(let [i0 {:id 0 :name "foo"}

0 commit comments

Comments
 (0)