Method: Puppet::Network::HTTP::Response#respond_with

Defined in:
lib/puppet/network/http/response.rb

#respond_with(code, type, body) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/puppet/network/http/response.rb', line 9

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