class JIRA::HttpClient
Constants
- DEFAULT_OPTIONS
Attributes
options[R]
Public Class Methods
new(options)
click to toggle source
# File lib/jira/http_client.rb, line 16 def initialize(options) @options = DEFAULT_OPTIONS.merge(options) @cookies = {} end
Public Instance Methods
authenticated?()
click to toggle source
# File lib/jira/http_client.rb, line 66 def authenticated? @authenticated end
basic_auth_http_conn()
click to toggle source
# File lib/jira/http_client.rb, line 41 def basic_auth_http_conn http_conn(uri) end
http_conn(uri)
click to toggle source
# File lib/jira/http_client.rb, line 45 def http_conn(uri) if @options[:proxy_address] http_class = Net::HTTP::Proxy(@options[:proxy_address], @options[:proxy_port] ? @options[:proxy_port] : 80) else http_class = Net::HTTP end http_conn = http_class.new(uri.host, uri.port) http_conn.use_ssl = @options[:use_ssl] if @options[:use_client_cert] http_conn.cert = @options[:cert] http_conn.key = @options[:key] end http_conn.verify_mode = @options[:ssl_verify_mode] http_conn.read_timeout = @options[:read_timeout] http_conn end
make_request(http_method, url, body='', headers={})
click to toggle source
# File lib/jira/http_client.rb, line 28 def make_request(http_method, url, body='', headers={}) # When a proxy is enabled, Net::HTTP expects that the request path omits the domain name path = request_path(url) request = Net::HTTP.const_get(http_method.to_s.capitalize).new(path, headers) request.body = body unless body.nil? add_cookies(request) if options[:use_cookies] request.basic_auth(@options[:username], @options[:password]) if @options[:username] && @options[:password] response = basic_auth_http_conn.request(request) @authenticated = response.is_a? Net::HTTPOK store_cookies(response) if options[:use_cookies] response end
uri()
click to toggle source
# File lib/jira/http_client.rb, line 62 def uri uri = URI.parse(@options[:site]) end
Private Instance Methods
request_path(url)
click to toggle source
# File lib/jira/http_client.rb, line 72 def request_path(url) parsed_uri = URI(url) return url unless parsed_uri.is_a?(URI::HTTP) parsed_uri.request_uri end