Skip to content

Allow for specifying the preferred auth schemes in http requests. #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,26 @@ missed, etc:

#+END_SRC


** Preferred Authentication
:PROPERTIES:
:CUSTOM_ID: h-c29486f9-8c54-11e9-acb1-90b11c96f2d2
:END:

To select the preferred authentication scheme:

#+BEGIN_SRC clojure

(client/get "http://example.com/protected" {:auth-schemes ["NTLM"]})

#+END_SRC

#+BEGIN_SRC clojure

(client/get "http://example.com/protected" {:proxy-auth-schemes ["BASIC" "DIGEST"]})

#+END_SRC

* Advanced Usage
:PROPERTIES:
:CUSTOM_ID: h-d52ca837-a575-402f-81fe-53241d85f2db
Expand Down
8 changes: 6 additions & 2 deletions src/clj_http/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@
cookie-spec
; deprecated
conn-request-timeout
conn-timeout]
conn-timeout
auth-schemes
proxy-auth-schemes]
:as req}]
(let [config (-> (RequestConfig/custom)
(.setConnectTimeout (or connection-timeout conn-timeout -1))
Expand All @@ -198,7 +200,9 @@
(boolean (opt req :allow-circular-redirects)))
(.setRelativeRedirectsAllowed
((complement false?)
(opt req :allow-relative-redirects))))]
(opt req :allow-relative-redirects)))
(.setTargetPreferredAuthSchemes auth-schemes)
(.setProxyPreferredAuthSchemes proxy-auth-schemes))]
(if cookie-spec
(.setCookieSpec config CUSTOM_COOKIE_POLICY)
(.setCookieSpec config (get-cookie-policy req)))
Expand Down