我試圖找到一種方法來檢查網頁是否存在於Haskell中。服務器只有HTTP2/HTTPS,我試圖檢查頁面是否存在於servant應用程序中。獲取Haskell中網頁的狀態代碼
是否有任何Haskell包具有良好的文檔來檢查狀態碼是200還是404?並使用強大的HTTPS和HTTP2服務器? (握手失敗(Error_Protocol(「期待服務器你好,得到警報:[(AlertLevel_Fatal,HandshakeFailure)]」,True,HandshakeFailure)))這是我目前與http-conduit,但我收到奇怪的異常(TlsExceptionHostPort 「thibaud.dauce.fr」443和StatusCodeException)。
... other imports
import qualified Network.HTTP.Conduit as HTTP
... other types
type AppM = ReaderT Config (EitherT ServantErr IO)
newComment :: String -> OneComment -> AppM Int64
newComment baseUrl oneComment = do
time <- liftIO getCurrentTime
response <- HTTP.withManager $ \manager -> do
request <- HTTP.parseUrl $ url oneComment
HTTP.httpLbs request manager
case (statusIsSuccessful $ HTTP.responseStatus response, startswith baseUrl (url oneComment)) of
(_, False) -> return 0
(True, True) -> do
theNewComment <- runDb $ insert $ Comment (url oneComment) (content oneComment) time
return $ fromSqlKey theNewComment
_ -> return 0
一些例子來看看['wreq'包(http://www.serpentine.com/wreq/) – ErikR