Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make the sample work and update it with documentation about how net-h…

…ttp-pipeline works. Issue #1
  • Loading branch information...
commit b25d160d88808b80734e0c3d93015a28e79861a4 1 parent 7c592a3
@drbrain authored
Showing with 22 additions and 13 deletions.
  1. +1 −1  Manifest.txt
  2. +21 −0 sample/pipeline.rb
  3. +0 −12 sample/two_get.rb
View
2  Manifest.txt
@@ -4,5 +4,5 @@ Manifest.txt
README.txt
Rakefile
lib/net/http/pipeline.rb
-sample/two_get.rb
+sample/pipeline.rb
test/test_net_http_pipeline.rb
View
21 sample/pipeline.rb
@@ -0,0 +1,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
+
View
12 sample/two_get.rb
@@ -1,12 +0,0 @@
-require 'net/http/pipeline'
-
-Net::HTTP.start 'localhost' do |http|
- req1 = Net::HTTP::Get.new '/'
- req2 = Net::HTTP::Get.new '/'
-
- http.pipeline req1, req2 do |res|
- puts res.code
- puts res.body[0..60].inspect
- puts
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.