Skip to content

Commit

Permalink
Follow http-access2.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
nahi committed Feb 13, 2003
1 parent 0d877be commit 7a9ec08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sample/dav.rb
Expand Up @@ -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
16 changes: 10 additions & 6 deletions sample/howto.rb
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions sample/thread.rb
Expand Up @@ -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 )
}
Expand All @@ -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'

0 comments on commit 7a9ec08

Please sign in to comment.