summaryrefslogtreecommitdiff
path: root/Remote/Helper/Http.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-08-08 17:17:36 -0400
committerJoey Hess <joey@kitenet.net>2014-08-08 17:17:36 -0400
commit1dd3232e8e90b2aa49b670284eb90f7d500eae57 (patch)
tree9db05190eb302da27844d395c96c1d0527274ed9 /Remote/Helper/Http.hs
parent1f8c170c953cefa8eccb6c3ba50b1b05494060b1 (diff)
check for 200 response
Diffstat (limited to 'Remote/Helper/Http.hs')
-rw-r--r--Remote/Helper/Http.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/Remote/Helper/Http.hs b/Remote/Helper/Http.hs
index d4882b8c8f..f1d576d1c9 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