Sha256: 3e01b9264d7349ace904cd8da642973c50a9a18cd72fb2aa003be80c0a8608e3

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 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
    @response_headers['Content-Type']
  end

  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

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.22.0 lib/nitro/response.rb
nitro-0.23.0 lib/nitro/response.rb
nitro-0.24.0 lib/nitro/cgi/response.rb
nitro-0.25.0 lib/nitro/cgi/response.rb
nitro-0.26.0 lib/nitro/cgi/response.rb