Net :: HttpGenericRequest中body
与body_stream
之间的区别是什么? Documentation says...empty.
示例代码:
uri = URI('http://www.example.com/todo.cgi')
req = Net::HTTP::Post.new(uri.path)
req.body = "ABCDEF"
req.body_stream = "ABCDEF" # Any difference?
答案 0 :(得分:0)
我认为区别在于每个人收到的论点,正如您在文档中看到的那样。
http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTPGenericRequest.html#method-i-body-3D
Net :: HTTPGenericRequest#body 收到字符串作为参数。
req.body("ABCDEF")
Net :: HTTPGenericRequest#body_stream 收到输入作为参数。
req.body_stream(File.open("/tmp/example.txt"))
我希望这会对你有所帮助。