Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Follow http-access2.rb

  • Loading branch information...
commit 7a9ec089b725a480fdbb945d9c583f31216b4999 1 parent 0d877be
nahi authored
Showing with 20 additions and 10 deletions.
  1. +1 −1  sample/dav.rb
  2. +10 −6 sample/howto.rb
  3. +9 −3 sample/thread.rb
View
2  sample/dav.rb
@@ -47,6 +47,6 @@ def put( local, target = nil )
targetUri = @uri + target
out.puts( "Sending file #{ local }." )
res = @client.put( targetUri, File.open( local, "rb" ), @headers )
- out.puts res.body.content
+ out.puts res.content.read
end
end
View
16 sample/howto.rb
@@ -20,26 +20,30 @@
p result.header[ 'content-type' ][ 0 ]
puts '== Body object'
p result.body
+puts '== Content(IO)'
+p result.content
puts '== Content'
-print result.body.content
+print result.content.read
puts
puts '= GET with query'
-puts clnt.get( target, { "foo" => "bar", "baz" => "quz" } ).body.content
+puts clnt.get( target, { "foo" => "bar", "baz" => "quz" } ).content.read
puts
puts '= GET with query 2'
-puts clnt.get( target, [[ "foo", "bar1" ], [ "foo", "bar2" ]] ).body.content
-
+puts clnt.get( target, [[ "foo", "bar1" ], [ "foo", "bar2" ]] ).content.read
+# Client must be reset here to set debugDev.
+# Setting debugDev to keep-alive session is ignored.
+clnt.reset( target )
clnt.debugDev = STDERR
puts
puts '= GET with extraHeader'
-puts clnt.get( target, nil, { "SOAPAction" => "HelloWorld" } ).body.content
+puts clnt.get( target, nil, { "SOAPAction" => "HelloWorld" } ).content.read
puts
puts '= GET with extraHeader 2'
-puts clnt.get( target, nil, [[ "Accept", "text/plain" ], [ "Accept", "text/html" ]] ).body.content
+puts clnt.get( target, nil, [[ "Accept", "text/plain" ], [ "Accept", "text/html" ]] ).content.read
clnt.debugDev = STDERR
clnt.debugDev = nil
View
12 sample/thread.rb
@@ -6,9 +6,11 @@
proxy = ENV[ 'HTTP_PROXY' ] || ENV[ 'http_proxy' ]
h = HTTPAccess2::Client.new( proxy )
+count = 20
+
res = []
g = []
-for i in 0..29
+for i in 0..count
g << Thread.new {
res[ i ] = h.get( urlstr )
}
@@ -18,8 +20,12 @@
th.join
end
-for i in 0..28
- raise unless ( res[ i ].body.content == res[ i + 1 ].body.content )
+res.map! do |item|
+ item.content.read
+end
+
+for i in 0..(count - 1)
+ raise unless ( res[ i ] == res[ i + 1 ] )
end
puts 'ok'
Please sign in to comment.
Something went wrong with that request. Please try again.