check for 200 response
This commit is contained in:
parent
1f8c170c95
commit
1dd3232e8e
1 changed files with 5 additions and 3 deletions
|
@ -11,7 +11,8 @@ import Common.Annex
|
|||
import Types.StoreRetrieve
|
||||
import Utility.Metered
|
||||
import Remote.Helper.Special
|
||||
import Network.HTTP.Client (RequestBody(..), Response, responseBody, BodyReader)
|
||||
import Network.HTTP.Client (RequestBody(..), Response, responseStatus, responseBody, BodyReader)
|
||||
import Network.HTTP.Types
|
||||
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.ByteString as S
|
||||
|
@ -38,8 +39,9 @@ httpStorer a = fileStorer $ \k f m -> do
|
|||
-- Reads the http body and stores it to the specified file, updating the
|
||||
-- meter as it goes.
|
||||
httpBodyRetriever :: FilePath -> MeterUpdate -> Response BodyReader -> IO ()
|
||||
httpBodyRetriever dest meterupdate resp =
|
||||
bracket (openBinaryFile dest WriteMode) hClose (go zeroBytesProcessed)
|
||||
httpBodyRetriever dest meterupdate resp
|
||||
| responseStatus resp /= ok200 = error $ show $ responseStatus resp
|
||||
| otherwise = bracket (openBinaryFile dest WriteMode) hClose (go zeroBytesProcessed)
|
||||
where
|
||||
reader = responseBody resp
|
||||
go sofar h = do
|
||||
|
|
Loading…
Add table
Reference in a new issue