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