Class: Gitlab::QA::Support::GetRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/support/get_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, token) ⇒ GetRequest

Returns a new instance of GetRequest.



12
13
14
15
# File 'lib/gitlab/qa/support/get_request.rb', line 12

def initialize(uri, token)
  @uri = uri
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/gitlab/qa/support/get_request.rb', line 10

def token
  @token
end

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/gitlab/qa/support/get_request.rb', line 10

def uri
  @uri
end

Instance Method Details

#execute!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/qa/support/get_request.rb', line 17

def execute!
  response = with_retry_on_too_many_requests do
    Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
      http.request(build_request)
    end
  end

  case response
  when Net::HTTPSuccess
    response
  else
    raise Support::InvalidResponseError.new(uri.to_s, response)
  end
end