Sha256: 4ba302850260a03cc23edfb1cb7e70f37b3e996294e3030c6aff075cbf243cb0

Contents?: true

Size: 999 Bytes

Versions: 5

Compression:

Stored size: 999 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

  # Return the content type for this response.
  
  def content_type
    @response_headers['Content-Type']
  end

  # Set the content type for this response.
  
  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.27.0 lib/nitro/cgi/response.rb
nitro-0.28.0 lib/nitro/cgi/response.rb
nitro-0.29.0 lib/nitro/cgi/response.rb
nitro-0.30.0 lib/nitro/cgi/response.rb
nitro-0.31.0 lib/nitro/cgi/response.rb