Sha256: 1c75ea6c5a94077c0855db0c9361139fef147492febb3d4fd2c235662eb52dd5

Contents?: true

Size: 975 Bytes

Versions: 107

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

require 'net/http'

module Seahorse
  module Client
    # @api private
    module NetHttp

      # @api private
      module Patches

        def self.apply!
          Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
          return unless RUBY_VERSION < '2.5'

          Net::HTTP::IDEMPOTENT_METHODS_.clear
        end

        # For requests with bodys, Net::HTTP sets a default content type of:
        #   'application/x-www-form-urlencoded'
        # There are cases where we should not send content type at all.
        # Even when no body is supplied, Net::HTTP uses a default empty body
        # and sets it anyway. This patch disables the behavior when a Thread
        # local variable is set.
        module PatchDefaultContentType
          def supply_default_content_type
            return if Thread.current[:net_http_skip_default_content_type]

            super
          end
        end

      end
    end
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
aws-sdk-core-3.187.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.187.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.186.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.185.2 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.185.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.185.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.184.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.183.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.183.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.182.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.181.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.181.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.180.3 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.180.2 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.180.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.180.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.179.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.178.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.177.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.176.1 lib/seahorse/client/net_http/patches.rb