class Puppet::Network::HTTP::Response

Public Class Methods

new(handler, response) click to toggle source
  # File lib/puppet/network/http/response.rb
3 def initialize(handler, response)
4   @handler = handler
5   @response = response
6 end

Public Instance Methods

respond_with(code, type, body) click to toggle source
   # File lib/puppet/network/http/response.rb
 8 def respond_with(code, type, body)
 9   format = Puppet::Network::FormatHandler.format_for(type)
10   mime = format.mime
11   charset = format.charset
12 
13   if charset
14     if body.is_a?(String) && body.encoding != charset
15       body.encode!(charset)
16     end
17 
18     mime += "; charset=#{charset.name.downcase}"
19   end
20 
21   @handler.set_content_type(@response, mime)
22   @handler.set_response(@response, body, code)
23 end