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.



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

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

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/gitlab/qa/support/get_request.rb', line 8

def token
  @token
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/gitlab/qa/support/get_request.rb', line 8

def uri
  @uri
end

Instance Method Details

#execute!Object



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

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