Sha256: 57a38c8782b65d37e8205e9600ad5d75668278ac69d5e597512a4e4c0c42c679

Contents?: true

Size: 960 Bytes

Versions: 2

Compression:

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.41.0 lib/nitro/cgi/response.rb
nitro-0.40.0 lib/nitro/cgi/response.rb