我正在使用Rails 3。我刚刚安装了Typhoeus,我是tryng来发出这样的HTTP请求。
require 'typhoeus'
....
request = Typhoeus::Request.new("http://google.com",
:method => :get,
:params => {
:email => "test@test.com",
:password => "test"
}
)
resp = request.response但是我有一个问题:resp的调试始终是空白的,如果我不使用选项(方法、params、.),也会发生这种情况。
但是,如果我使用以下代码,它将工作:
resp = Typhoeus::Request.get("http://google.com?email=test@test.com&password=test")我将得到resp的值。
有什么问题吗?
我所用的
如果你需要更多的信息,请告诉我。
在正式文件中,有一些与安装相关的Mac用户的警告(过写)。
终端产出:
$ which ruby
/Users/<my_user_name>/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
$ which curl
/opt/local/bin/curl发布于 2011-02-22 14:47:15
您需要在九头蛇中运行请求:
request = Typhoeus::Request.new
hydra = Typhoeus::Hydra.new
hydra.queue(request)
hydra.run
request.response #=> "response"我的猴子修补台风,这样它将自动排队在九头蛇,如果它还没有运行。
发布于 2012-10-06 20:13:42
Typhoeus::Request.get而它的好友发布,上传,删除,头,补丁都是捷径,会立即发出请求。如果手动创建请求,则必须在之后运行该请求:
request = Typhoeus::Request.new("www.example.com")
request.run
#=> <Typhoeus::Response ...>我不建议对单个请求使用水龙头,因为这会拖慢你的脚步。这是文档:http://rubydoc.info/github/typhoeus/typhoeus/Typhoeus/Request。
https://stackoverflow.com/questions/5079302
复制相似问题