Bound authentication probe startup synchronization
This commit is contained in:
parent
9ad8d27adf
commit
b196f9e17b
1 changed files with 36 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
|||
module Nuthatch.Probe.Curl
|
||||
( CurlResponse (..)
|
||||
, CurlTransportFailure (..)
|
||||
, cookieValue
|
||||
, curl
|
||||
, curlToFile
|
||||
|
|
@ -7,6 +8,7 @@ module Nuthatch.Probe.Curl
|
|||
, headerValues
|
||||
) where
|
||||
|
||||
import Control.Exception (Exception, throwIO)
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Data.ByteString.Char8 as B8
|
||||
import Data.Char (toLower)
|
||||
|
|
@ -23,6 +25,13 @@ data CurlResponse = CurlResponse
|
|||
, curlBody :: BS.ByteString
|
||||
} deriving stock (Eq, Show)
|
||||
|
||||
data CurlTransportFailure = CurlTransportFailure
|
||||
{ curlTransportExitCode :: Int
|
||||
, curlTransportStderr :: String
|
||||
} deriving stock (Eq, Show)
|
||||
|
||||
instance Exception CurlTransportFailure
|
||||
|
||||
curl :: [String] -> IO CurlResponse
|
||||
curl arguments =
|
||||
withSystemTempDirectory "nuthatch-curl" $ \directory -> do
|
||||
|
|
@ -56,12 +65,10 @@ runCurl outputPath arguments =
|
|||
case exitCode of
|
||||
ExitSuccess -> pure ()
|
||||
ExitFailure code ->
|
||||
fail
|
||||
( "curl transport failed with exit "
|
||||
<> show code
|
||||
<> ": "
|
||||
<> stderrText
|
||||
)
|
||||
throwIO CurlTransportFailure
|
||||
{ curlTransportExitCode = code
|
||||
, curlTransportStderr = stderrText
|
||||
}
|
||||
headers <- parseHeaders <$> BS.readFile headersPath
|
||||
pure CurlResponse
|
||||
{ curlStatus = status
|
||||
|
|
|
|||
Loading…
Reference in a new issue