File: pipeline.rb

package info (click to toggle)
ruby-net-http-pipeline 1.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 152 kB
  • sloc: ruby: 687; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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