答案 0 :(得分:14)
Network.HTTP.Conduit
有一个干净的API(它使用Network.HTTP.Types
),如果您对管道有所了解,则使用起来非常简单。例如:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Conduit
import Network.HTTP.Conduit
import qualified Data.Aeson as J
main =
do manager <- newManager def
initReq <- parseUrl "https://api.github.com/user"
let req = applyBasicAuth "niklasb" "password" initReq
resp <- runResourceT $ httpLbs req manager
print (responseStatus resp)
print (lookup "content-type" (responseHeaders resp))
-- you will probably want a proper FromJSON instance here,
-- rather than decoding to Data.Aeson.Object
print (J.decode (responseBody resp) :: Maybe J.Object)
另请确保consult the tutorial。
答案 1 :(得分:12)
答案 2 :(得分:5)
除了Network.HTTP.Conduit
Network.Http.Client
,它还会公开io-streams
界面。
答案 3 :(得分:1)