Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d1425725
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d1425725
编写于
12月 16, 2011
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get rid of the close checks since we cannot reliably close the session anyway.
上级
8015f906
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
1 addition
and
165 deletion
+1
-165
actionpack/lib/action_dispatch.rb
actionpack/lib/action_dispatch.rb
+0
-1
actionpack/lib/action_dispatch/middleware/closed_error.rb
actionpack/lib/action_dispatch/middleware/closed_error.rb
+0
-7
actionpack/lib/action_dispatch/middleware/cookies.rb
actionpack/lib/action_dispatch/middleware/cookies.rb
+0
-10
actionpack/lib/action_dispatch/middleware/flash.rb
actionpack/lib/action_dispatch/middleware/flash.rb
+0
-6
actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
.../lib/action_dispatch/middleware/session/abstract_store.rb
+0
-4
actionpack/test/controller/flash_test.rb
actionpack/test/controller/flash_test.rb
+0
-40
actionpack/test/dispatch/cookies_test.rb
actionpack/test/dispatch/cookies_test.rb
+1
-97
未找到文件。
actionpack/lib/action_dispatch.rb
浏览文件 @
d1425725
...
...
@@ -63,7 +63,6 @@ module ActionDispatch
autoload
:Static
end
autoload
:ClosedError
,
'action_dispatch/middleware/closed_error'
autoload
:MiddlewareStack
,
'action_dispatch/middleware/stack'
autoload
:Routing
...
...
actionpack/lib/action_dispatch/middleware/closed_error.rb
已删除
100644 → 0
浏览文件 @
8015f906
module
ActionDispatch
class
ClosedError
<
StandardError
#:nodoc:
def
initialize
(
kind
)
super
"Cannot modify
#{
kind
}
because it was closed. This means it was already streamed back to the client or converted to HTTP headers."
end
end
end
actionpack/lib/action_dispatch/middleware/cookies.rb
浏览文件 @
d1425725
...
...
@@ -121,10 +121,6 @@ def initialize(secret = nil, host = nil, secure = false)
@cookies
=
{}
end
attr_reader
:closed
alias
:closed?
:closed
def
close!
;
@closed
=
true
end
def
each
(
&
block
)
@cookies
.
each
(
&
block
)
end
...
...
@@ -165,7 +161,6 @@ def handle_options(options) #:nodoc:
# Sets the cookie named +name+. The second argument may be the very cookie
# value, or a hash of options as documented above.
def
[]=
(
key
,
options
)
raise
ClosedError
,
:cookies
if
closed?
if
options
.
is_a?
(
Hash
)
options
.
symbolize_keys!
value
=
options
[
:value
]
...
...
@@ -259,7 +254,6 @@ def initialize(parent_jar, secret)
end
def
[]=
(
key
,
options
)
raise
ClosedError
,
:cookies
if
closed?
if
options
.
is_a?
(
Hash
)
options
.
symbolize_keys!
else
...
...
@@ -298,7 +292,6 @@ def [](name)
end
def
[]=
(
key
,
options
)
raise
ClosedError
,
:cookies
if
closed?
if
options
.
is_a?
(
Hash
)
options
.
symbolize_keys!
options
[
:value
]
=
@verifier
.
generate
(
options
[
:value
])
...
...
@@ -352,9 +345,6 @@ def call(env)
end
[
status
,
headers
,
body
]
ensure
cookie_jar
=
ActionDispatch
::
Request
.
new
(
env
).
cookie_jar
unless
cookie_jar
cookie_jar
.
close!
end
end
end
actionpack/lib/action_dispatch/middleware/flash.rb
浏览文件 @
d1425725
...
...
@@ -93,7 +93,6 @@ def initialize_copy(other)
end
def
[]=
(
k
,
v
)
#:nodoc:
raise
ClosedError
,
:flash
if
closed?
keep
(
k
)
@flashes
[
k
]
=
v
end
...
...
@@ -159,10 +158,6 @@ def now
@now
||=
FlashNow
.
new
(
self
)
end
attr_reader
:closed
alias
:closed?
:closed
def
close!
;
@closed
=
true
;
end
# Keeps either the entire current flash or a specific flash entry available for the next action:
#
# flash.keep # keeps the entire flash
...
...
@@ -258,7 +253,6 @@ def call(env)
end
env
[
KEY
]
=
new_hash
new_hash
.
close!
end
if
session
.
key?
(
'flash'
)
&&
session
[
'flash'
].
empty?
...
...
actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
浏览文件 @
d1425725
...
...
@@ -74,10 +74,6 @@ def stale_session_check!
class
AbstractStore
<
Rack
::
Session
::
Abstract
::
ID
include
Compatibility
include
StaleSessionCheck
def
destroy_session
(
env
,
sid
,
options
)
raise
'#destroy_session needs to be implemented.'
end
end
end
end
actionpack/test/controller/flash_test.rb
浏览文件 @
d1425725
...
...
@@ -254,16 +254,6 @@ def test_just_using_flash_does_not_stream_a_cookie_back
end
end
def
test_setting_flash_raises_after_stream_back_to_client
with_test_route_set
do
env
=
{
'action_dispatch.request.flash_hash'
=>
ActionDispatch
::
Flash
::
FlashHash
.
new
}
get
'/set_flash'
,
nil
,
env
assert_raise
(
ActionDispatch
::
ClosedError
)
{
@request
.
flash
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_flash_does_not_raise_in_following_requests
with_test_route_set
do
env
=
{
'action_dispatch.request.flash_hash'
=>
ActionDispatch
::
Flash
::
FlashHash
.
new
}
...
...
@@ -280,36 +270,6 @@ def test_setting_flash_now_does_not_raise_in_following_requests
end
end
def
test_setting_flash_raises_after_stream_back_to_client_even_with_an_empty_flash
with_test_route_set
do
env
=
{
'action_dispatch.request.flash_hash'
=>
ActionDispatch
::
Flash
::
FlashHash
.
new
}
get
'/dont_set_flash'
,
nil
,
env
assert_raise
(
ActionDispatch
::
ClosedError
)
{
@request
.
flash
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_flash_now_raises_after_stream_back_to_client
with_test_route_set
do
env
=
{
'action_dispatch.request.flash_hash'
=>
ActionDispatch
::
Flash
::
FlashHash
.
new
}
get
'/set_flash_now'
,
nil
,
env
assert_raise
(
ActionDispatch
::
ClosedError
)
{
@request
.
flash
.
now
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_flash_now_raises_after_stream_back_to_client_even_with_an_empty_flash
with_test_route_set
do
env
=
{
'action_dispatch.request.flash_hash'
=>
ActionDispatch
::
Flash
::
FlashHash
.
new
}
get
'/dont_set_flash'
,
nil
,
env
assert_raise
(
ActionDispatch
::
ClosedError
)
{
@request
.
flash
.
now
[
'alert'
]
=
'alert'
}
end
end
private
# Overwrite get to send SessionSecret in env hash
...
...
actionpack/test/dispatch/cookies_test.rb
浏览文件 @
d1425725
...
...
@@ -564,100 +564,4 @@ def assert_not_cookie_header(expected)
assert_not_equal
expected
.
split
(
"
\n
"
),
header
end
end
end
class
CookiesIntegrationTest
<
ActionDispatch
::
IntegrationTest
SessionKey
=
'_myapp_session'
SessionSecret
=
'b3c631c314c0bbca50c1b2843150fe33'
class
TestController
<
ActionController
::
Base
def
dont_set_cookies
head
:ok
end
def
set_cookies
cookies
[
"that"
]
=
"hello"
head
:ok
end
end
def
test_setting_cookies_raises_after_stream_back_to_client
with_test_route_set
do
get
'/set_cookies'
assert_raise
(
ActionDispatch
::
ClosedError
)
{
request
.
cookie_jar
[
'alert'
]
=
'alert'
cookies
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_cookies_raises_after_stream_back_to_client_even_without_cookies
with_test_route_set
do
get
'/dont_set_cookies'
assert_raise
(
ActionDispatch
::
ClosedError
)
{
request
.
cookie_jar
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_permanent_cookies_raises_after_stream_back_to_client
with_test_route_set
do
get
'/set_cookies'
assert_raise
(
ActionDispatch
::
ClosedError
)
{
request
.
cookie_jar
.
permanent
[
'alert'
]
=
'alert'
cookies
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_permanent_cookies_raises_after_stream_back_to_client_even_without_cookies
with_test_route_set
do
get
'/dont_set_cookies'
assert_raise
(
ActionDispatch
::
ClosedError
)
{
request
.
cookie_jar
.
permanent
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_signed_cookies_raises_after_stream_back_to_client
with_test_route_set
do
get
'/set_cookies'
assert_raise
(
ActionDispatch
::
ClosedError
)
{
request
.
cookie_jar
.
signed
[
'alert'
]
=
'alert'
cookies
[
'alert'
]
=
'alert'
}
end
end
def
test_setting_signed_cookies_raises_after_stream_back_to_client_even_without_cookies
with_test_route_set
do
get
'/dont_set_cookies'
assert_raise
(
ActionDispatch
::
ClosedError
)
{
request
.
cookie_jar
.
signed
[
'alert'
]
=
'alert'
}
end
end
private
# Overwrite get to send SessionSecret in env hash
def
get
(
path
,
parameters
=
nil
,
env
=
{})
env
[
"action_dispatch.secret_token"
]
||=
SessionSecret
super
end
def
with_test_route_set
with_routing
do
|
set
|
set
.
draw
do
match
':action'
,
:to
=>
CookiesIntegrationTest
::
TestController
end
@app
=
self
.
class
.
build_app
(
set
)
do
|
middleware
|
middleware
.
use
ActionDispatch
::
Cookies
middleware
.
delete
"ActionDispatch::ShowExceptions"
end
yield
end
end
end
end
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录