Sha256: 0c554b522afe27fc8fa28ec294c31bef1d1d830a534503ea422de323156a776a

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

module Nitro
	
# HTTP Response. This module is included in Context.

module Response

	# The Response status.

	attr_accessor :status

	# The Response headers.

	attr_accessor :response_headers

	# The Response cookies.

	attr_accessor :response_cookies

	def content_type=(ctype)
		@response_headers['Content-Type'] = ctype
	end

	# Add a cookie to the response. Better use this
	# method to avoid precreating the cookies array
	# for every request.
	#
	# === Examples
	#
	# add_cookie('nsid', 'gmosx')
	# add_cookie(Cookie.new('nsid', 'gmosx')
	
	def add_cookie(cookie, value = nil)
		if value
			(@response_cookies ||= []) << Cookie.new(cookie, value)
		else 
			(@response_cookies ||= []) << cookie
		end
	end
	alias_method :send_cookie, :add_cookie

end

end

# * George Moschovitis  <gm@navel.gr>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.19.0 lib/nitro/response.rb
nitro-0.20.0 lib/nitro/response.rb