Tag: 遏制

使用Ruby curb执行HTTP PATCH

我正在尝试使用curb进行HTTP PATCH。 查看代码,似乎没有为此公开方法。 有没有办法用路边做PATCH? 如果没有,Ruby中还有哪些其他库或方法可以实现这一目标?

如何用Ruby的法拉第指定网络接口?

我正在使用Faraday包装各种适配器,包括Net :: HTTP,Excon,Typhoeus,Patron和EventMachine。 我想指定网络接口(例如en0或en1 ),但我不确定如何或是否可能。 我愿意接受Ruby级别或Linux级别的答案。 注意:根据使用Ruby和Curb从不同网络接口发出HTTP请求 ,这可以通过Curb实现 。

使用gem Curb(curl)下载文件

我已经明白我可以使用RubyGem Curb来满足我将文件卷入计算机的需求。 但我无法弄清楚如何实际“触摸”该文件。 这是我到目前为止所得到的 include ‘rubygems’ include ‘curb’ curl = Curl::Easy.new(‘http://wordpress.org/latest.zip’) curl.perform 我想我明白, perform实际上是下载文件。 但是之后如何与文件进行交互? 它在哪里下载到? 此致,马蒂亚斯

Ruby:如何使用Curb发送JSON POST请求?

如何将CURB请求的请求主体设置为我的json字符串? 我正在尝试使用Curb执行JSON POST请求。 我的代码: require ‘rubygems’ require ‘curb’ require ‘json’ myarray = {} myarray[‘key’] = ‘value’ json_string = myarray.to_json() c = Curl::Easy.http_post(“https://example.com” # how do I set json_string to be the request body? ) do |curl| curl.headers[‘Accept’] = ‘application/json’ curl.headers[‘Content-Type’] = ‘application/json’ curl.headers[‘Api-Version’] = ‘2.2’ end

从Curb获取响应标头

我打算从Ruby on Rails应用程序调用: c = Curl::Easy.http_post(“https://example.com”, json_string_goes_here) do |curl| curl.headers[‘Accept’] = ‘application/json’ curl.headers[‘Content-Type’] = ‘application/json’ curl.headers[‘Api-Version’] = ‘2.2’ end 响应应该有自定义标头: X-Custom1 : “some value” X-Custom2 : “another value” 如何迭代响应头以将值与我期望的值进行比较?