net-http

    6热度

    2回答

    我想从一个URL解析XML文件。当我尝试这样的事情: require 'net/http' require 'rubygems' require 'xmlsimple' url = 'http://my-address.com/xmltest/note.xml' xml_data = Net::HTTP.get_response(URI.parse(url)).body 一切正常,但

    15热度

    3回答

    我有一项任务是通过自动化测试URL上的不同用户代理。我使用ruby进行编码,并且我一直在尝试使用以下方法设置用户代理,但似乎无法识别用户代理。 @http = Net::HTTP.new(URL) response = @http.request_get(URL, {'User-Agent' => useragent}) 有没有其他方法可以做到这一点,或者我做错了什么?

    1热度

    2回答

    我正在尝试编写一个ruby脚本,该脚本使用net/http获取关于网站上文件的一些详细信息。我的代码如下所示: require 'open-uri' require 'net/http' url = URI.parse asset res = Net::HTTP.start(url.host, url.port) {|http| http.get(asset) } head

    5热度

    2回答

    我正在用omniauth/openid进行一些操作。 当试图进行身份验证,我发现这个在我的日志: OpenID::FetchingError: Error fetching https://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username: undefined method `

    0热度

    1回答

    有人可以指出我对Net :: HTTP有很好的资源吗?我试图理解为什么某些代码按照它的方式工作。例如: def url_check(domain) parsed = URI.parse(domain).host check = Net::HTTP.new(parsed).head('/').kind_of? Net::HTTPOK (check == true ? "

    1热度

    1回答

    在要求open-uri之后,可以通过Kernel#open方便地下载和使用网络上的文件。但是,尝试使用https执行此操作会导致发生根证书错误,因为ruby没有所有的根证书。 这可以解决like this,但这是一个块使用Net::HTTP对象。 有一种优雅的方式来设置为Net::HTTP库use_ssl和ca_file全球范围内,使之适用于我的整个应用程序和命令一样Kernel#open?