Sha256: 2156cd0c3b9d81a0b011108883066ec6ef56586125f82fb10df48d20d663fbbd

Contents?: true

Size: 883 Bytes

Versions: 59

Compression:

Stored size: 883 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)
        end

        # For requests with bodies, 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

59 entries across 59 versions & 1 rubygems

Version Path
aws-sdk-core-3.220.2 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.220.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.220.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.219.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.218.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.218.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.217.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.217.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.216.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.216.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.215.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.215.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.214.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.214.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.213.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.212.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.211.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.210.0 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.209.1 lib/seahorse/client/net_http/patches.rb
aws-sdk-core-3.209.0 lib/seahorse/client/net_http/patches.rb