无法使用Net :: HTTP在我的ruby代码中发出HTTP删除请求

问题描述:

我在我的ruby代码中使用Net :: HTTP来发出http请求。例如,我要发帖子请求

Im using Net::HTTP in my ruby code to make http requests. For example to make a post request i do

require 'net/http'
Net::HTTP.post_form(url,{'email' => email,'password' => password})

这个作品。但我无法发出删除请求,即

This works. But im unable to make a delete request, i.e.

require 'net/http'
Net::HTTP::Delete(url)

出现以下错误

NoMethodError: undefined method `Delete' for Net::HTTP:Class

http: //ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html 显示删除可用。那么为什么我的情况不起作用?

The documentation at http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html shows Delete is available. So why is it not working in my case ?

谢谢

文档告诉你Net :: HTTP :: Delete是一个类,而不是一个方法。

The documentation tells you that Net::HTTP::Delete is a class, not a method.

尝试 Net :: HTTP.new('www.server.com')。delete('/ path')相反。