summaryrefslogtreecommitdiff
path: root/lib/gitlab_net.rb
diff options
context:
space:
mode:
authorAkzhan <akzhan.abdulin@gmail.com>2013-03-23 16:14:10 +0400
committerAkzhan <akzhan.abdulin@gmail.com>2013-03-23 16:14:10 +0400
commitacdeb0bf1f7660031183e5fea785d6d665013284 (patch)
treecf5bbd1c02107d2e38981daa312bc267cf780ca5 /lib/gitlab_net.rb
parent601450c30d66a17b3b445f0ca7367eae458efcdd (diff)
downloadgitlab-shell-acdeb0bf1f7660031183e5fea785d6d665013284.tar.gz
http_settings configuration option added.
Now it supports: * self_signed_cert option to allow self-signed certificates over https protocol. * user and password options to pass though http auth.
Diffstat (limited to 'lib/gitlab_net.rb')
-rw-r--r--lib/gitlab_net.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 884d95e..ef4d915 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -30,15 +30,28 @@ class GitlabNet
protected
+ def config
+ @config ||= GitlabConfig.new
+ end
+
def host
- "#{GitlabConfig.new.gitlab_url}/api/v3/internal"
+ "#{config.gitlab_url}/api/v3/internal"
end
def get(url)
url = URI.parse(url)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.port == 443)
+
+ if config.http_settings['self_signed_cert'] && http.use_ssl?
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+
request = Net::HTTP::Get.new(url.request_uri)
+ if config.http_settings['user'] && config.http_settings['password']
+ request.basic_auth config.http_settings['user'], config.http_settings['password']
+ end
+
http.start {|http| http.request(request) }
end
end