Maybe a silly way to do things, but here it goes. I wanted to split the HTTP request send/receive from processing the response.
import Pipes
import qualified Pipes.HTTP as HTTP
import Pipes.Core
import qualified Pipes.ByteString as PB
import Network.Socket (withSocketsDo)
fetch m url = do
req <- lift $ HTTP.parseUrl url
resp <- lift $ HTTP.withHTTP req m return
url' <- respond $ HTTP.responseBody resp
fetch m url'
client :: Client String (Producer PB.ByteString IO ()) IO ()
client = do
b <- request "http://www.google.com"
lift $ runEffect $ b >-> PB.stdout
main = withSocketsDo $ HTTP.withManager HTTP.tlsManagerSettings $ \m ->
runEffect $ fetch m +>> client
Seems legitimate. But I get part of response printed and "Network.Socket.ByteString.recv: failed (Unknown error)". What do I need to do differently?