summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab_net.rb3
-rw-r--r--lib/http_codes.rb5
-rw-r--r--lib/http_helper.rb4
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 980897a..5af2da6 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -35,7 +35,8 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
url = "#{internal_api_endpoint}/allowed"
resp = post(url, params)
- if resp.code == '200'
+ case resp.code.to_s
+ when HTTP_SUCCESS, HTTP_UNAUTHORIZED, HTTP_NOT_FOUND
GitAccessStatus.create_from_json(resp.body)
else
GitAccessStatus.new(false,
diff --git a/lib/http_codes.rb b/lib/http_codes.rb
new file mode 100644
index 0000000..24b3b5a
--- /dev/null
+++ b/lib/http_codes.rb
@@ -0,0 +1,5 @@
+module HTTPCodes
+ HTTP_SUCCESS = '200'.freeze
+ HTTP_UNAUTHORIZED = '401'.freeze
+ HTTP_NOT_FOUND = '404'.freeze
+end
diff --git a/lib/http_helper.rb b/lib/http_helper.rb
index 62d0c51..1e75833 100644
--- a/lib/http_helper.rb
+++ b/lib/http_helper.rb
@@ -1,4 +1,8 @@
+require_relative 'http_codes'
+
module HTTPHelper
+ include HTTPCodes
+
READ_TIMEOUT = 300
protected