Module: Koala::NetHTTPService

Includes:
HTTPService
Defined in:
lib/koala/http_services/net_http_service.rb

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from HTTPService

included

Class Attribute Details

.ca_fileObject

Returns the value of attribute ca_file.



12
13
14
# File 'lib/koala/http_services/net_http_service.rb', line 12

def ca_file
  @ca_file
end

.ca_pathObject

Returns the value of attribute ca_path.



12
13
14
# File 'lib/koala/http_services/net_http_service.rb', line 12

def ca_path
  @ca_path
end

.verify_modeObject

Returns the value of attribute verify_mode.



12
13
14
# File 'lib/koala/http_services/net_http_service.rb', line 12

def verify_mode
  @verify_mode
end

Class Method Details

.make_request(path, args, verb, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/koala/http_services/net_http_service.rb', line 15

def self.make_request(path, args, verb, options = {})
  # We translate args to a valid query string. If post is specified,
  # we send a POST request to the given path with the given arguments.

  # by default, we use SSL only for private requests
  # this makes public requests faster
  private_request = args["access_token"] || @always_use_ssl || options[:use_ssl]

  # if the verb isn't get or post, send it as a post argument
  args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"

  http = create_http(server(options), private_request, options)

  response = http.start do |http|
    if verb == "post"
      if params_require_multipart? args
        http.request Net::HTTP::Post::Multipart.new path, encode_multipart_params(args)
      else
        http.post(path, encode_params(args))
      end
    else
      http.get("#{path}?#{encode_params(args)}")
    end
  end

  Koala::Response.new(response.code.to_i, response.body, response)
end