Sha256: fe5a9ba0e3d2d8a909b50be7a2a943efea4d3eca1a76e4e15338883cd343644e

Contents?: true

Size: 588 Bytes

Versions: 20

Compression:

Stored size: 588 Bytes

Contents

# frozen_string_literal: true
class Puppet::Network::HTTP::Response
  def initialize(handler, response)
    @handler = handler
    @response = response
  end

  def respond_with(code, type, body)
    format = Puppet::Network::FormatHandler.format_for(type)
    mime = format.mime
    charset = format.charset

    if charset
      if body.is_a?(String) && body.encoding != charset
        body.encode!(charset)
      end

      mime += "; charset=#{charset.name.downcase}"
    end

    @handler.set_content_type(@response, mime)
    @handler.set_response(@response, body, code)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/network/http/response.rb
puppet-8.3.0-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.3.0-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.3.0-universal-darwin lib/puppet/network/http/response.rb
puppet-8.3.1 lib/puppet/network/http/response.rb
puppet-8.3.1-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.3.1-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.3.1-universal-darwin lib/puppet/network/http/response.rb
puppet-8.2.0 lib/puppet/network/http/response.rb
puppet-8.2.0-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.2.0-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.2.0-universal-darwin lib/puppet/network/http/response.rb
puppet-8.1.0 lib/puppet/network/http/response.rb
puppet-8.1.0-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.1.0-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.1.0-universal-darwin lib/puppet/network/http/response.rb
puppet-8.0.1 lib/puppet/network/http/response.rb
puppet-8.0.1-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.0.1-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.0.1-universal-darwin lib/puppet/network/http/response.rb