diff options
author | Joey Hess <joey@kitenet.net> | 2014-08-08 17:17:36 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-08-08 17:17:36 -0400 |
commit | 068b5f24417681425a3b0a8b706bfe19b89922ba (patch) | |
tree | 856ad0bfb516558b7a7f9f3c27ae4c46943b13c8 /Remote/Helper | |
parent | dc5e727becdddc09f76e2065b1d56e07053ee062 (diff) |
check for 200 response
Diffstat (limited to 'Remote/Helper')
-rw-r--r-- | Remote/Helper/Http.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Remote/Helper/Http.hs b/Remote/Helper/Http.hs index d4882b8c8..f1d576d1c 100644 --- a/Remote/Helper/Http.hs +++ b/Remote/Helper/Http.hs @@ -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 |