Sha256: bae4e814c5a3398736e3248e8f0f02ab6c22259115a5662acba4e68a7c916aa6

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

require 'net/http/pipeline'

http = Net::HTTP.new 'localhost'
http.set_debug_output $stderr # so you can see what is happening
# http.pipelining = true # set this when localhost:80 is an HTTP/1.1 server

http.start do |http|
  reqs = []
  reqs << Net::HTTP::Get.new('/?a') # this request will be non-pipelined
                                    # to check if localhost:80 is HTTP/1.1
                                    # unless http.pipelining == true
  reqs << Net::HTTP::Get.new('/?b') # these requests will be pipelined
  reqs << Net::HTTP::Get.new('/?c')

  http.pipeline reqs do |res|
    puts res.code
    puts res.body[0..60].inspect
    puts
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
net-http-pipeline-1.0.1 sample/pipeline.rb