Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 检查wreq请求头_Haskell - Fatal编程技术网

Haskell 检查wreq请求头

Haskell 检查wreq请求头,haskell,Haskell,我对哈斯凯尔还很陌生,我不知道如何才能做到这一点。我使用的是HTTP客户端,我想检查哪些HTTP头被发送到服务器。例如,我定义了以下方法,该方法尝试使用Facebook凭据进行身份验证: authenticate ⦂ String → String → IO (Response ByteString) authenticate facebookId facebookToken = postWith opts "https://api.somedomain.com/auth" (objec

我对哈斯凯尔还很陌生,我不知道如何才能做到这一点。我使用的是HTTP客户端,我想检查哪些HTTP头被发送到服务器。例如,我定义了以下方法,该方法尝试使用Facebook凭据进行身份验证:

authenticate ⦂ String → String → IO (Response ByteString)
authenticate facebookId facebookToken =
    postWith opts "https://api.somedomain.com/auth" (object $ ["facebook_token" .= facebookToken, "facebook_id" .= facebookId])
      where opts = defaults & header "Content-Type" .~ ["application/json"]
                            & header "Accept" .~ ["application/json"]
                            & proxy ?~ httpProxy "localhost" 9396
有了邮递员,我得到了正确的回复,但有了
wreq
我得到了禁止访问(403)。我假设库可能会添加一些额外的请求头,这就是我想要检查的

有什么提示吗


编辑:http代理现在用于检查http通信量(
wreq
请求未被检测到)。

在wreq中,
选项
类型是
显示
的实例,因此您可以将其传递给,或仅在ghci上检查:

ghci> import Network.Wreq
ghci> defaults :: Options
Options { manager = Left _, proxy = Nothing, auth = Nothing, headers = 
[("User-Agent","haskell wreq-0.3.0.1")], params = [], redirects = 10, cookies = [] }
您还可以使用镜头直接聚焦标题:

ghci> defaults ^. headers
[("User-Agent","haskell wreq-0.3.0.1")]

但是,如果Wreq在将选项传递到
postWith
之后添加了一些头文件,那么您必须使用web调试代理来了解发生了什么。

谢谢。我正在尝试使用web代理,但没有成功,未检测到使用
wreq
触发的请求。见更新的问题。有什么想法吗?最后,这是一个不相关的问题(
https
请求不受直接监控)。作为将来的参考,您可以使用来检查这些内容。真是太棒了。