Session 如何在法拉第设置cookie

Session 如何在法拉第设置cookie,session,cookies,sinatra,faraday,Session,Cookies,Sinatra,Faraday,我使用法拉第作为HTTP客户端来测试我的HTTP服务(基于Sinatra)。它对我来说非常强大,但我有个问题 我们跟踪Sinatra服务上的会话,但我无法使用Faraday客户端设置cookie值。这是示例代码: # `response` is from the Sinatra service cookie = response.headers['set-cookie'] # now, for the follow up request... response = client.get '/a

我使用法拉第作为HTTP客户端来测试我的HTTP服务(基于Sinatra)。它对我来说非常强大,但我有个问题

我们跟踪Sinatra服务上的会话,但我无法使用Faraday客户端设置cookie值。这是示例代码:

# `response` is from the Sinatra service
cookie = response.headers['set-cookie']

# now, for the follow up request...
response = client.get '/api/profile' do |req|
  req.headers['Cookie'] = cookie
end

服务器找不到会话。为什么?

设置Cookie和
Cookie
标题不一样,请阅读RFC以了解如何解释它们。简而言之,
Set Cookie
标题还包含客户机如何处理数据(域、路径、到期日等)的说明,并更新现有Cookie存储。另一方面,
Cookie
头提供Cookie存储的内容,但不提供元数据


您需要获取或实现某种cookie处理程序,以插入法拉第中间件堆栈。

conn.response:logger
添加到法拉第中间件,如中所示。然后,请分享你的Sinatra和Faraday日志,最好是链接到a。我添加了日志,但它不会再次出错。也许这是我在其他地方的错误。我很抱歉这似乎填补了这个空白。