【发布时间】:2018-06-11 14:36:26
【问题描述】:
当 http 代码不成功并且我希望 不 创建文件时,我需要从 getSrc 返回什么值(通过 sinkFile)
如果我只是返回 getResponseBody res,则 http 错误本身会保存到文件中。
downloadURL :: String -> FilePath -> IO ()
downloadURL url location = do
request <- parseRequest url
runResourceT
$ runConduit$ httpSource request getSrc
.| sinkFile location
where
getSrc res = do
let success = statusIsSuccessful . getResponseStatus $ res
if success then
getResponseBody res
else
???
【问题讨论】:
-
你想做什么?