Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Note that responses are returned in-order

The documentation didn't clearly explain that pipelined HTTP requests
are returned in-order.  This is a slight improvement, but sample/ really
needs a full-up WEBrick example.

See also #3
  • Loading branch information...
commit 4a0ccad70dc6a3f9579d700de10cd858526683e3 1 parent c45a2aa
@drbrain authored
Showing with 19 additions and 9 deletions.
  1. +9 −4 README.txt
  2. +9 −4 lib/net/http/pipeline.rb
  3. +1 −1  sample/pipeline.rb
View
13 README.txt
@@ -17,10 +17,10 @@ The server will respond in-order.
require 'net/http/pipeline'
- Net::HTTP.start 'localhost' do |http|
- req1 = Net::HTTP::Get.new '/'
- req2 = Net::HTTP::Get.new '/'
- req3 = Net::HTTP::Get.new '/'
+ Net::HTTP.start 'example' do |http|
+ req1 = Net::HTTP::Get.new '/?response_body=a'
+ req2 = Net::HTTP::Get.new '/?response_body=b'
+ req3 = Net::HTTP::Get.new '/?response_body=c'
http.pipeline [req1, req2, req3] do |res|
puts res.code
@@ -29,6 +29,11 @@ The server will respond in-order.
end
end
+Since pipelined requests must be return in submission order the responses
+will come in the same order as submission. If http://example/ places the
++response_body+ parameter in the body of the response this will print "a" then
+"b" then "c".
+
== INSTALL:
gem install net-http-pipeline
View
13 lib/net/http/pipeline.rb
@@ -16,11 +16,11 @@
#
# require 'net/http/pipeline'
#
-# Net::HTTP.start 'localhost' do |http|
+# Net::HTTP.start 'example' do |http|
# requests = []
-# requests << Net::HTTP::Get.new('/')
-# requests << Net::HTTP::Get.new('/')
-# requests << Net::HTTP::Get.new('/')
+# requests << Net::HTTP::Get.new('/?response_body=a')
+# requests << Net::HTTP::Get.new('/?response_body=b')
+# requests << Net::HTTP::Get.new('/?response_body=c')
#
# http.pipeline requests do |res|
# puts res.code
@@ -28,6 +28,11 @@
# puts
# end
# end
+#
+# Since pipelined requests must be return in submission order the responses
+# will come in the same order as submission. If http://example/ places the
+# +response_body+ parameter in the body of the response this will print "a"
+# then "b" then "c".
module Net::HTTP::Pipeline
View
2  sample/pipeline.rb
@@ -1,6 +1,6 @@
require 'net/http/pipeline'
-http = Net::HTTP.new 'localhost'
+http = Net::HTTP.new 'example'
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
Please sign in to comment.
Something went wrong with that request. Please try again.