mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the cookie itself. Based on a patch by Arthur Schreiber [ruby-core:17634]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a0c569a378
commit
5904f64dbf
2 changed files with 18 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Sep 14 06:42:21 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
|
* lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the
|
||||||
|
cookie itself. Based on a patch by Arthur Schreiber [ruby-core:17634]
|
||||||
|
|
||||||
Mon Sep 14 05:21:12 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
Mon Sep 14 05:21:12 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
* lib/net/http.rb (fetch): Handle properly default values; a patch by
|
* lib/net/http.rb (fetch): Handle properly default values; a patch by
|
||||||
|
|
|
@ -55,11 +55,10 @@ class CGI
|
||||||
def initialize(name = "", *value)
|
def initialize(name = "", *value)
|
||||||
if name.kind_of?(String)
|
if name.kind_of?(String)
|
||||||
@name = name
|
@name = name
|
||||||
@value = value
|
|
||||||
%r|^(.*/)|.match(ENV["SCRIPT_NAME"])
|
%r|^(.*/)|.match(ENV["SCRIPT_NAME"])
|
||||||
@path = ($1 or "")
|
@path = ($1 or "")
|
||||||
@secure = false
|
@secure = false
|
||||||
return super(@value)
|
return super(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
options = name
|
options = name
|
||||||
|
@ -68,7 +67,7 @@ class CGI
|
||||||
end
|
end
|
||||||
|
|
||||||
@name = options["name"]
|
@name = options["name"]
|
||||||
@value = Array(options["value"])
|
value = Array(options["value"])
|
||||||
# simple support for IE
|
# simple support for IE
|
||||||
if options["path"]
|
if options["path"]
|
||||||
@path = options["path"]
|
@path = options["path"]
|
||||||
|
@ -80,12 +79,20 @@ class CGI
|
||||||
@expires = options["expires"]
|
@expires = options["expires"]
|
||||||
@secure = options["secure"] == true ? true : false
|
@secure = options["secure"] == true ? true : false
|
||||||
|
|
||||||
super(@value)
|
super(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor("name", "value", "path", "domain", "expires")
|
attr_accessor("name", "path", "domain", "expires")
|
||||||
attr_reader("secure")
|
attr_reader("secure")
|
||||||
|
|
||||||
|
def value
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def value=(val)
|
||||||
|
replace(Array(val))
|
||||||
|
end
|
||||||
|
|
||||||
# Set whether the Cookie is a secure cookie or not.
|
# Set whether the Cookie is a secure cookie or not.
|
||||||
#
|
#
|
||||||
# +val+ must be a boolean.
|
# +val+ must be a boolean.
|
||||||
|
@ -96,7 +103,7 @@ class CGI
|
||||||
|
|
||||||
# Convert the Cookie to its string representation.
|
# Convert the Cookie to its string representation.
|
||||||
def to_s
|
def to_s
|
||||||
val = @value.kind_of?(String) ? CGI::escape(@value) : @value.collect{|v| CGI::escape(v) }.join("&")
|
val = collect{|v| CGI::escape(v) }.join("&")
|
||||||
buf = "#{@name}=#{val}"
|
buf = "#{@name}=#{val}"
|
||||||
buf << "; domain=#{@domain}" if @domain
|
buf << "; domain=#{@domain}" if @domain
|
||||||
buf << "; path=#{@path}" if @path
|
buf << "; path=#{@path}" if @path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue