Sha256: b139cad85b39ad5bb737d00475f6c27520b535a355e4b282593ee7e016a1bcc3

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

# code:
# * George Moschovitis  <gm@navel.gr>
#
# (c) 2004 Navel, all rights reserved.
# $Id: cookie.rb 112 2004-10-27 10:59:55Z gmosx $

require "cgi"

class CGI

# Override the default class.

class Cookie

=begin
	# Override default implementation to convert a single value
	# array to a simple value.

	def value
		val = @value

		if 1 == val.size
			return val.first
		else
			return val
		end
	end
=end

end

end # class CGI

module N

# = Cookie
#
# An encapsulation of the standard HTTP Cookie.
#
# === Design
#
# Ruby's default cgi library implements the functionality,
# so we reuse it here!
#
# The http request contains only key/values pairs so we
# dont keep a full object.
#
# === Future
#
# - switch to libapreq!
#
class Cookie < CGI::Cookie

	# Override default implementation
	#
	def initialize(name, *value)
		super

		# this is a temporal fix! We should switch to libapreq,
		# or a custom implementation anyway, because cgi.rb
		# sucks.
		@path = "/"
	end

	# parse:
	# parses cookies from a header string
	#
	# Example cookie string, all cookies in one line separated by ;
	#
	# Cookie: nsid=293230807; nauth=gmosx:meMXs0ifW7JBQ; multi=123&456
	#
	# Input:
	# the header string
	# Output:
	# a hash object containing key-values pairs. notice that multiple
	# values can be assigned to one key, so values is an array. The
	# separator for mulriple values is '&'
	#
	# uses the default CGI implementation
	#
	# === Todo:
	#
	# - change this to return an array of Cookie objects!

end

end # module

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nitro-0.3.0 lib/n/server/cookie.rb
nitro-0.7.0 lib/nitro/server/cookie.rb
nitro-0.8.0 lib/nitro/server/cookie.rb