Sha256: c21e1a5b0bba69644f989707f5c73b42d2ae5c295672aeb139e650e394298e87

Contents?: true

Size: 589 Bytes

Versions: 32

Compression:

Stored size: 589 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

32 entries across 32 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/network/http/response.rb
puppet-8.10.0-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.10.0-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.10.0-universal-darwin lib/puppet/network/http/response.rb
puppet-8.9.0 lib/puppet/network/http/response.rb
puppet-8.9.0-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.9.0-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.9.0-universal-darwin lib/puppet/network/http/response.rb
puppet-8.8.1 lib/puppet/network/http/response.rb
puppet-8.8.1-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.8.1-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.8.1-universal-darwin lib/puppet/network/http/response.rb
puppet-8.7.0 lib/puppet/network/http/response.rb
puppet-8.7.0-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.7.0-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.7.0-universal-darwin lib/puppet/network/http/response.rb
puppet-8.6.0 lib/puppet/network/http/response.rb
puppet-8.6.0-x86-mingw32 lib/puppet/network/http/response.rb
puppet-8.6.0-x64-mingw32 lib/puppet/network/http/response.rb
puppet-8.6.0-universal-darwin lib/puppet/network/http/response.rb