Sha256: a62ed40bcf82ef08d93b00146cea9deea3bf7af39d95845a7cf54e9d3a4c5a49

Contents?: true

Size: 847 Bytes

Versions: 109

Compression:

Stored size: 847 Bytes

Contents

require 'net/http'
require 'uri'

module Gitlab
  module QA
    module Support
      class GetRequest
        attr_reader :uri, :token

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

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

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

        private

        def build_request
          Net::HTTP::Get.new(uri).tap do |req|
            req['PRIVATE-TOKEN'] = token
            req['Cookie'] = ENV['QA_COOKIES'] if ENV['QA_COOKIES']
          end
        end
      end
    end
  end
end

Version data entries

109 entries across 109 versions & 1 rubygems

Version Path
gitlab-qa-7.10.0 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.9.3 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.9.2 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.9.1 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.9.0 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.8.5 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.8.4 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.8.3 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.8.2 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.8.1 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.8.0 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.7.3 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.7.2 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.7.1 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.7.0 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.6.0 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.5.0 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.4.0 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.3.1 lib/gitlab/qa/support/get_request.rb
gitlab-qa-7.3.0 lib/gitlab/qa/support/get_request.rb