Class: Fogbugz::Adapter::HTTP::NetHttp
- Inherits:
-
Object
- Object
- Fogbugz::Adapter::HTTP::NetHttp
- Defined in:
- lib/ruby_fogbugz/adapters/http/net_http.rb
Instance Attribute Summary collapse
-
#requester ⇒ Object
Returns the value of attribute requester.
-
#root_url ⇒ Object
Returns the value of attribute root_url.
Instance Method Summary collapse
- #build_request(uri, params) ⇒ Object
-
#initialize(options = {}) ⇒ NetHttp
constructor
A new instance of NetHttp.
- #request(action, options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ NetHttp
Returns a new instance of NetHttp.
11 12 13 14 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 11 def initialize( = {}) @root_url = [:uri] @ca_file = [:ca_file] end |
Instance Attribute Details
#requester ⇒ Object
Returns the value of attribute requester.
9 10 11 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 9 def requester @requester end |
#root_url ⇒ Object
Returns the value of attribute root_url.
9 10 11 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 9 def root_url @root_url end |
Instance Method Details
#build_request(uri, params) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 16 def build_request(uri, params) return Net::HTTP::Post::Multipart.new(uri.request_uri, params) if params.key? :File1 request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(params) request end |
#request(action, options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_fogbugz/adapters/http/net_http.rb', line 24 def request(action, ) uri = URI("#{@root_url}/api.asp") params = { 'cmd' => action } params.merge!([:params]) request = build_request(uri, params) http = Net::HTTP.new(uri.host, uri.port) if @root_url.start_with? 'https' http.use_ssl = true http.ca_file = @ca_file end response = http.start { |h| h.request(request) } response.body end |