@@ -39,6 +39,7 @@ import Data.Aeson (FromJSON (..),
3939 (.:) , (.=) )
4040import qualified Data.ByteString.Char8 as S
4141import qualified Data.ByteString.Lazy as L
42+ import Data.Maybe (fromMaybe )
4243import Data.Text (Text )
4344import qualified Data.Text as T
4445import Data.Text.Encoding (encodeUtf8 )
@@ -47,15 +48,16 @@ import Data.Typeable (Typeable)
4748import Network.HTTP.Client (BodyReader , Manager ,
4849 Response ,
4950 RequestBody (RequestBodyLBS ),
50- applyBasicAuth , brRead ,
51+ brRead ,
5152 newManager ,
5253 parseRequest ,
5354 requestHeaders ,
5455 responseBody ,
5556 responseStatus ,
5657 withResponse )
5758import Network.HTTP.Client.MultipartFormData (formDataBody , partFileRequestBody )
58- import Network.HTTP.Client.TLS (tlsManagerSettings )
59+ import Network.HTTP.Client.TLS (tlsManagerSettings ,
60+ applyDigestAuth )
5961import Network.HTTP.Types (statusCode )
6062import Path (toFilePath )
6163import Prelude -- Fix redundant import warnings
@@ -203,13 +205,14 @@ mkUploader config us = do
203205 { upload_ = \ tarName bytes -> do
204206 let formData = [partFileRequestBody " package" tarName (RequestBodyLBS bytes)]
205207 req2 <- formDataBody formData req1
206- let req3 = applyBasicAuth
208+ mreq3 <- applyDigestAuth
207209 (encodeUtf8 $ hcUsername creds)
208210 (encodeUtf8 $ hcPassword creds)
209211 req2
212+ manager
210213 putStr $ " Uploading " ++ tarName ++ " ... "
211214 hFlush stdout
212- withResponse req3 manager $ \ res ->
215+ withResponse (fromMaybe req2 mreq3) manager $ \ res ->
213216 case statusCode $ responseStatus res of
214217 200 -> putStrLn " done!"
215218 401 -> do
0 commit comments