Sha256: ffe4563c9e4281f7f5bc25070e8dc35df16964944cbcb13908d9c3884392be30

Contents?: true

Size: 1.04 KB

Versions: 154

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.join('..', 'lib'))
require 'httpclient'

proxy = ENV['HTTP_PROXY']
clnt = HTTPClient.new(proxy)
clnt.set_cookie_store("cookie.dat")
target = ARGV.shift || "http://localhost/foo.cgi"

puts
puts '= GET content directly'
puts clnt.get_content(target)

puts '= GET result object'
result = clnt.get(target)
puts '== Header object'
p result.header
puts "== Content-type"
p result.contenttype
puts '== Body object'
p result.body
puts '== Content'
print result.content
puts '== GET with Block'
clnt.get(target) do |str|
  puts str
end

puts
puts '= GET with query'
puts clnt.get(target, { "foo" => "bar", "baz" => "quz" }).content

puts
puts '= GET with query 2'
puts clnt.get(target, [["foo", "bar1"], ["foo", "bar2"]]).content

clnt.debug_dev = STDERR
puts
puts '= GET with extra header'
puts clnt.get(target, nil, { "SOAPAction" => "HelloWorld" }).content

puts
puts '= GET with extra header 2'
puts clnt.get(target, nil, [["Accept", "text/plain"], ["Accept", "text/html"]]).content

clnt.debug_dev = nil

clnt.save_cookie_store

Version data entries

154 entries across 146 versions & 13 rubygems

Version Path
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/httpclient-2.8.3/sample/howto.rb
scout-5.9.12 vendor/httpclient/sample/howto.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/httpclient-2.8.3/sample/howto.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/httpclient-2.8.3/sample/howto.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/httpclient-2.8.3/sample/howto.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/httpclient-2.8.3/sample/howto.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/httpclient-2.8.3/sample/howto.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/httpclient-2.8.3/sample/howto.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/httpclient-2.8.3/sample/howto.rb
scout-5.9.11 vendor/httpclient/sample/howto.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/httpclient-2.8.3/sample/howto.rb
httpclient-2.8.3 sample/howto.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/httpclient-2.8.0/sample/howto.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/httpclient-2.8.0/sample/howto.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/httpclient-2.8.0/sample/howto.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/httpclient-2.8.0/sample/howto.rb
httpclient-2.8.2.4 sample/howto.rb
httpclient-2.8.2.3 sample/howto.rb
httpclient-2.8.2.2 sample/howto.rb
httpclient-2.8.2.1 sample/howto.rb