ruby - 使用气泡膜 : How to formulate get with custom headers?

标签 ruby http-headers rubymotion

我有以下有效的 Curl 命令:

curl -H "Authorization:GoogleLogin auth=xxx" http://www.google.com/reader/api/0/user-info

我尝试通过 BubbleWrap HTTP 中的 get 来执行此操作:

HTTP.get("http://www.google.com/reader/api/0/user-info",
    {
        :headers => { "Authorization:GoogleLogin auth" => "xxx"}
    }) do |response|
    puts response
    puts response.body.to_str
end

但是我收到了 401 返回,所以也许我没有正确设置 header ?

最佳答案

header 名称应为 Authorization,值为 GoogleLogin auth=xxx。按照您的操作方式,它是 Authorization:GoogleLogin auth 的 header 名称,值为 xxx。试试这个:

:headers => {"Authorization" => "GoogleLogin auth=xxx"}

关于ruby - 使用气泡膜 : How to formulate get with custom headers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14176770/

相关文章:

php - 使用 PHP 将 POST 数据发送到网站

ios - 如何使用 iOS 应用程序的 UIWebview 持续监控响应 header

objective-c - 更改 UIBarButtonItem 的字体

ios - 使用 Interface Builder 组织标签

ruby-on-rails - Phusion Passenger 处理具有多个 RVM ruby 的多个项目的问题

ruby-on-rails - 无法使用ssl在puma上运行rails应用程序

ruby - 只读应用程序无法使用 twitter ruby​​ gem 进行 POST

http - 服务器如何知道发送的请求带有凭据?

sql - 无法在 Ruby on Rails 中对 DISTINCT 值求和

javascript - 无法使用 Axios 从 Http POST 请求中获取 header