Permalink
Browse files

* added samples for async interface. closes #157.

  • Loading branch information...
1 parent dbf236f commit d5613d7d9a56503a667802bb93c3d81fb475f4d6 nahi committed Jun 23, 2007
Showing with 29 additions and 0 deletions.
  1. +8 −0 sample/async.rb
  2. +21 −0 sample/stream.rb
View
@@ -0,0 +1,8 @@
+require 'http-access2'
+
+c = HTTPAccess2::Client.new
+conn = c.get_async("http://www.ruby-lang.org/en/")
+io = conn.pop.content
+while str = io.read(40)
+ p str
+end
View
@@ -0,0 +1,21 @@
+$:.unshift(File.join('..', 'lib'))
+require "http-access2"
+
+c = HTTPClient.new
+
+piper, pipew = IO.pipe
+conn = c.post_async("http://localhost:8080/stream", piper)
+
+Thread.new do
+ res = conn.pop
+ while str = res.content.read(10)
+ p str
+ end
+end
+
+p "type here"
+while line = STDIN.gets
+ pipew << line
+end
+pipew.close
+sleep 5

0 comments on commit d5613d7

Please sign in to comment.