📜  传输编码 chunked ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:46.930000             🧑  作者: Mango

代码示例1
require 'net/http'

streamURL = 'http://localhost/sample-stream.php'

uri = URI.parse(streamURL)

Net::HTTP.start(uri.host, uri.port) do |http|
  request = Net::HTTP::Get.new uri.request_uri

  http.request request do |response|
    response.read_body do |chunk|
       #We get the data here chunk-by-chunk
       puts chunk
    end
  end
end