 
 (def ^Base64 base64 (Base64.))
 
-(defn spnego-authentication
-  "Returns an Authentication$Result for endpoint which will use SPNEGO to generate an Authorization header"
-  [^URI endpoint]
+(defn create-spnego-authentication-result-factory
+  "Returns an Authentication$Result for an endpoint which will use SPNEGO to generate the header value for the
+  provided authorization header field."
+  [^URI endpoint auth-header-field]
   (reify Authentication$Result
     (getURI [_] endpoint)
 


(defn ^HttpClient http-client-factory
  "Creates a HttpClient."
  [{:keys [clear-content-decoders conn-timeout socket-timeout user-agent]
    :or {clear-content-decoders true}
    :as config}]
  (let [^HttpClient client

    (.setUserAgentField client
                        (when-not (str/blank? user-agent)
                          (HttpField. HttpHeader/USER_AGENT (str user-agent))))
    (when proxy-url
      (let [proxy-uri (URI. proxy-url)
            configured-proxy (HttpProxy. (.getHost proxy-uri) (.getPort proxy-uri))
            ^ProxyConfiguration proxy-config (.getProxyConfiguration client)
            proxies (.getProxies proxy-config)]
        (.add proxies configured-proxy)
        (when proxy-spnego-auth
          (let [auth-store (.getAuthenticationStore client)]
            (.addAuthenticationResult auth-store (spnego-proxy-authentication proxy-uri))))))
    client))

(defn- prepare-http2-transport
