simpleHttp导致“不支持的浏览器响应?”

时间:2016-11-25 18:04:36

标签: http haskell

我正在向https域执行simpleHttp请求,但响应html显示“不支持的浏览器”消息 - 我相信这是因为simpleHttp不支持HTTPS。

我的功能:

import Network.HTTP.Simple

makeRequest :: IO LAZ.ByteString
makeRequest = do
  response <- simpleHttp "https://www.example.com"
  return (response)

哪些haskell库支持https?

2 个答案:

答案 0 :(得分:2)

Wreq使用基本镜头语法提供了一个非常容易理解的http / s请求教程。

https兼容请求非常简单:

main = do
  r <- get "https://www.example.com"

可以分别访问响应状态和正文:

  r ^. responseStatus . statusCode
  r ^. responseBody

答案 1 :(得分:0)

此代码无法编译。即使添加window.addEventListener('DOMContentLoaded', function(e) { var observer = new MutationObserver( onContentMutated ); var options = { attributes: true, childList: false, characterData: false, subtree: false, attributeFilter: ['class'] }; var iframeContainers = document.querySelectorAll('.tabs-content .content'); for(var i = 0; i < iframeContainers.length; i++) { observer.observe( iframeContainers[i], options ); } }); function onContentMutated(mutations) { for(var i = 0; i < mutations.length; i++) { var m = mutations[i]; var thisIsNowAnActiveTab = m.target.classList.contains('active'); if( thisIsNowAnActiveTab ) { // get the corresponding iframe and fiddle with its DOM var iframes = m.target.getElementsByTagName("iframe"); if( iframes.length == 0 ) continue; var iframe = iframes[0]; iframe.contentWindow.document.documentElement.style.overflow = 'hidden'; // the timeout is to trigger Chrome to recompute the necessity of the scrollbars, which makes them visible again. Because the timeout period is 0 there should be no visible change to users. setTimeout( function(s) { s.overflow = 'auto'; }, 0, iframe.contentWindow.document.documentElement.style ); } console.log( m.type ); } } 导入,LAZ模块也不会提供Network.HTTP.Simple功能。您可以使用simpleHttp

执行此操作
httpLBS

或者使用{-# LANGUAGE OverloadedStrings #-} import Network.HTTP.Simple import qualified Data.ByteString.Lazy as LAZ makeRequest :: IO LAZ.ByteString makeRequest = do response <- httpLBS "https://www.example.com" return (getResponseBody response) main :: IO () main = makeRequest >>= LAZ.putStr 中的simpleHttp函数:

Network.HTTP.Conduit

请注意,{-# LANGUAGE OverloadedStrings #-} import Network.HTTP.Conduit import qualified Data.ByteString.Lazy as LAZ makeRequest :: IO LAZ.ByteString makeRequest = simpleHttp "https://www.example.com" main :: IO () main = makeRequest >>= LAZ.putStr 在表面下使用与http-conduit(http-client)相同的HTTP引擎。我的猜测是你最初试图使用http-client本身的一个功能,但我不确定那个代码会是什么样子。