Class: Puppet::Network::HTTP::Response
- Defined in:
- lib/puppet/network/http/response.rb
Instance Method Summary collapse
-
#initialize(handler, response) ⇒ Response
constructor
A new instance of Response.
- #respond_with(code, type, body) ⇒ Object
Constructor Details
#initialize(handler, response) ⇒ Response
Returns a new instance of Response.
2 3 4 5 |
# File 'lib/puppet/network/http/response.rb', line 2 def initialize(handler, response) @handler = handler @response = response end |
Instance Method Details
#respond_with(code, type, body) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/puppet/network/http/response.rb', line 7 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 |