Bound authentication probe startup synchronization

This commit is contained in:
ms2k 2026-07-20 05:22:08 +09:00
commit b196f9e17b

View file

@ -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