Class: Net::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/tagen/net/http.rb

Class Method Summary collapse

Class Method Details

.get1(path, params, initheader = {}, &blk) ⇒ Object

support params

Examples:


get1("http://www.google.com/search", "&q=foo")
get1("http://www.google.com/search", {"q" => "foo"} )

Parameters:

  • params (String Hash)

    Hash by URI.encoding_www_form



16
17
18
19
20
# File 'lib/tagen/net/http.rb', line 16

def get1 path, params, initheader={}, &blk
  path = path + "?" + (String===params ? params : URI.encode_www_form(params))
  req = Get.new(path, initheader)
  request req, &blk
end

.post1(path, params, initheader = {}, &blk) ⇒ Object

support params

See Also:



25
26
27
28
29
30
31
32
33
34
# File 'lib/tagen/net/http.rb', line 25

def post1 path, params, initheader={}, &blk
  req = Post.new(path, initheader)
  if String===params
    req.body = params
    req.content_type = 'application/x-www-form-urlencoded'
  else
    req.set_form_data(params)
  end
  request req, &blk
end