Class: JIRA::HttpClient
- Inherits:
-
RequestClient
- Object
- RequestClient
- JIRA::HttpClient
- Defined in:
- lib/jira/http_client.rb
Overview
Client using HTTP Basic Authentication
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#authenticated? ⇒ Boolean
Returns true if the client is authenticated.
-
#initialize(options) ⇒ HttpClient
constructor
Generally not used directly, but through JIRA::Client.
- #make_cookie_auth_request ⇒ Object
-
#make_multipart_request(url, body, headers = {}) ⇒ Net::HTTPResponse
Makes a multipart request to the JIRA server.
-
#make_request(http_method, url, body = '', headers = {}) ⇒ Net::HTTPResponse
Makes a request to the JIRA server.
-
#uri ⇒ URI
The URI of the JIRA REST API call.
Methods inherited from RequestClient
Constructor Details
#initialize(options) ⇒ HttpClient
Generally not used directly, but through JIRA::Client. See JIRA::Client for documentation.
51 52 53 54 |
# File 'lib/jira/http_client.rb', line 51 def initialize() @options = DEFAULT_OPTIONS.merge() @cookies = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
40 41 42 |
# File 'lib/jira/http_client.rb', line 40 def @options end |
Instance Method Details
#authenticated? ⇒ Boolean
Returns true if the client is authenticated.
137 138 139 |
# File 'lib/jira/http_client.rb', line 137 def authenticated? @authenticated end |
#make_cookie_auth_request ⇒ Object
56 57 58 59 60 61 |
# File 'lib/jira/http_client.rb', line 56 def body = { username: @options[:username].to_s, password: @options[:password].to_s }.to_json @options.delete(:username) @options.delete(:password) make_request(:post, "#{@options[:context_path]}/rest/auth/1/session", body, 'Content-Type' => 'application/json') end |
#make_multipart_request(url, body, headers = {}) ⇒ Net::HTTPResponse
Makes a multipart request to the JIRA server.
This is used for file uploads.
Generally you should not call this method directly, but use the helper methods in JIRA::Client.
95 96 97 98 99 100 |
# File 'lib/jira/http_client.rb', line 95 def make_multipart_request(url, body, headers = {}) path = request_path(url) request = Net::HTTP::Post::Multipart.new(path, body, headers) execute_request(request) end |
#make_request(http_method, url, body = '', headers = {}) ⇒ Net::HTTPResponse
Makes a request to the JIRA server.
Generally you should not call this method directly, but use the helper methods in JIRA::Client.
File uploads are not supported with this method. Use make_multipart_request instead.
75 76 77 78 79 80 81 82 |
# File 'lib/jira/http_client.rb', line 75 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? execute_request(request) end |
#uri ⇒ URI
The URI of the JIRA REST API call
131 132 133 |
# File 'lib/jira/http_client.rb', line 131 def uri URI.parse(@options[:site]) end |