Class: Gitlab::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/http.rb

Direct Known Subclasses

Atlassian::JiraConnect::Client

Constant Summary collapse

BlockedUrlError =
Gitlab::HTTP_V2::BlockedUrlError
RedirectionTooDeep =
Gitlab::HTTP_V2::RedirectionTooDeep
ReadTotalTimeout =
Gitlab::HTTP_V2::ReadTotalTimeout
HeaderReadTimeout =
Gitlab::HTTP_V2::HeaderReadTimeout
SilentModeBlockedError =
Gitlab::HTTP_V2::SilentModeBlockedError
HTTP_TIMEOUT_ERRORS =
Gitlab::HTTP_V2::HTTP_TIMEOUT_ERRORS
HTTP_ERRORS =
Gitlab::HTTP_V2::HTTP_ERRORS
DEFAULT_TIMEOUT_OPTIONS =
{
  open_timeout: 10,
  read_timeout: 20,
  write_timeout: 30
}.freeze
DEFAULT_READ_TOTAL_TIMEOUT =
30.seconds
Error =

We are explicitly assigning these constants because they are used in the codebase.

HTTParty::Error
Response =
HTTParty::Response
ResponseError =
HTTParty::ResponseError
CookieHash =
HTTParty::CookieHash

Class Method Summary collapse

Class Method Details

.perform_request(http_method, path, options, &block) ⇒ Object

TODO: This method is subject to be removed We have this for now because we explicitly use the ‘perform_request` method in some places.



42
43
44
45
46
47
48
49
50
51
# File 'lib/gitlab/http.rb', line 42

def perform_request(http_method, path, options, &block)
  method_name = http_method::METHOD.downcase.to_sym

  unless ::Gitlab::HTTP_V2::SUPPORTED_HTTP_METHODS.include?(method_name)
    raise ArgumentError, "Unsupported HTTP method: '#{method_name}'."
  end

  # Use `::Gitlab::HTTP_V2.get/post/...` methods
  ::Gitlab::HTTP_V2.public_send(method_name, path, http_v2_options(options), &block) # rubocop:disable GitlabSecurity/PublicSend -- method is validated to make sure it is one of the methods in Gitlab::HTTP_V2::SUPPORTED_HTTP_METHODS
end

.try_get(path, options = {}, &block) ⇒ Object



34
35
36
37
38
# File 'lib/gitlab/http.rb', line 34

def try_get(path, options = {}, &block)
  get(path, options, &block)
rescue *HTTP_ERRORS
  nil
end