我试图找到一种方法来检查 Haskell 中是否存在网页。服务器仅是 HTTP2 / HTTPS,我正在尝试检查该页面是否存在于服务应用程序中。
是否有任何带有良好文档的 Haskell 包来检查状态码是 200 还是 404?并使用强大的 HTTPS 和 HTTP2 服务器?
这是我目前使用 http-conduit 所拥有的,但我收到了奇怪的异常(TlsExceptionHostPort (HandshakeFailed (Error_Protocol ("expecting server hello, got alert : [(AlertLevel_Fatal,HandshakeFailure)]",True,HandshakeFailure))) "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