Class: JIRA::HttpClient
- Inherits:
-
RequestClient
- Object
- RequestClient
- JIRA::HttpClient
- Defined in:
- lib/jira/http_client.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :username => '', :password => '' }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #basic_auth_http_conn ⇒ Object
- #http_conn(uri) ⇒ Object
-
#initialize(options) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #make_request(http_method, path, body = '', headers = {}) ⇒ Object
- #uri ⇒ Object
Methods inherited from RequestClient
Constructor Details
#initialize(options) ⇒ HttpClient
Returns a new instance of HttpClient.
15 16 17 18 |
# File 'lib/jira/http_client.rb', line 15 def initialize() = DEFAULT_OPTIONS.merge() = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/jira/http_client.rb', line 13 def end |
Instance Method Details
#basic_auth_http_conn ⇒ Object
30 31 32 |
# File 'lib/jira/http_client.rb', line 30 def basic_auth_http_conn http_conn(uri) end |
#http_conn(uri) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jira/http_client.rb', line 34 def http_conn(uri) if [:proxy_address] http_class = Net::HTTP::Proxy([:proxy_address], [:proxy_port] ? [:proxy_port] : 80) else http_class = Net::HTTP end http_conn = http_class.new(uri.host, uri.port) http_conn.use_ssl = [:use_ssl] http_conn.verify_mode = [:ssl_verify_mode] http_conn.read_timeout = [:read_timeout] http_conn end |
#make_request(http_method, path, body = '', headers = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/jira/http_client.rb', line 20 def make_request(http_method, path, body='', headers={}) request = Net::HTTP.const_get(http_method.to_s.capitalize).new(path, headers) request.body = body unless body.nil? (request) if [:use_cookies] request.basic_auth([:username], [:password]) response = basic_auth_http_conn.request(request) (response) if [:use_cookies] response end |
#uri ⇒ Object
47 48 49 |
# File 'lib/jira/http_client.rb', line 47 def uri uri = URI.parse([:site]) end |