Sha256: 1d05319f9072b2435bb1057232e764c20ada4236ec421363a3f4faf361b906d0

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require 'net/http'
require 'timeout'

require 'github_authentication/retriable'

module GithubAuthentication
  module Http
    class << self
      include Retriable

      def post(url)
        uri = URI.parse(url)
        with_retries(SystemCallError, Timeout::Error) do
          http = Net::HTTP.new(uri.host, uri.port)
          http.use_ssl = true
          http.start
          begin

            request = Net::HTTP::Post.new(uri.request_uri)
            yield(request) if block_given?

            http.request(request)
          ensure
            http.finish
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
github-authentication-1.0.2 lib/github_authentication/http.rb
github-authentication-1.0.1 lib/github_authentication/http.rb
github-authentication-1.0.0 lib/github_authentication/http.rb