Sha256: 520f6ac323f1e957d3e3e1077f1c2eac2babe12d872b12361edb77eb67afdff7

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

# = Http Cookie
#
# code:: gmosx
#
# (c) 2004 Navel, all rights reserved.
# $Id: cookie.rb 71 2004-10-18 10:50:22Z 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; module App

# 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.
#
# === Todo:
#
# - 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; end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.1.2 lib/n/app/cookie.rb