First I will give you the code, then the error, then some type information. The questions are these: How can I figure out what is going on? How might I fix the problem?
readTask = do
req' <- parseUrl "https://10.64.251.32/rest/api/latest/issue/BNAP-291"
manager <- newManager manSettings
let req'' = applyBasicAuth (pack "sandboxer") (pack "sandboxer") req'
Response _ _ _ body <-runResourceT $ http req'' manager
pBody <- runResourceT $
body $$+- sinkParser json
-- print pBody
-- closeManager manager
return ()
where manSettings =
def
{ managerCheckCerts = \ _ _ -> return CertificateUsageAccept }
This compiles fine. Here’s what happens when I run the compiled code
dist/build/Spike/Spike
Spike: <socket: 3>: hGetBuf: illegal operation (handle is closed)
body is the following type
Data.Conduit.Internal.ResumableSource
(Control.Monad.Trans.Resource.ResourceT IO)
Data.ByteString.Internal.ByteString
Feedback appreciated, I don’t know how to begin troubleshooting this.
The first
runResourceTcall is closing the socket before the body is parsed. You will need to combine the tworunResourceTcalls into one.ResourceTis aMonadinstance so you can usedonotation and some minor surgery to free the socket after parsing is complete: