Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
acb68484
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,发现更多精彩内容 >>
提交
acb68484
编写于
7月 27, 2012
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
threads can wait on responses to be committed
上级
f4d818d5
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
34 addition
and
1 deletion
+34
-1
actionpack/lib/action_controller/test_case.rb
actionpack/lib/action_controller/test_case.rb
+1
-0
actionpack/lib/action_dispatch/http/response.rb
actionpack/lib/action_dispatch/http/response.rb
+24
-1
actionpack/test/dispatch/response_test.rb
actionpack/test/dispatch/response_test.rb
+9
-0
未找到文件。
actionpack/lib/action_controller/test_case.rb
浏览文件 @
acb68484
...
@@ -226,6 +226,7 @@ def recycle!
...
@@ -226,6 +226,7 @@ def recycle!
@block
=
nil
@block
=
nil
@length
=
0
@length
=
0
@body
=
[]
@body
=
[]
@committed
=
false
@charset
=
@content_type
=
nil
@charset
=
@content_type
=
nil
@request
=
@template
=
nil
@request
=
@template
=
nil
end
end
...
...
actionpack/lib/action_dispatch/http/response.rb
浏览文件 @
acb68484
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
require
'active_support/core_ext/module/delegation'
require
'active_support/core_ext/module/delegation'
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/class/attribute_accessors'
require
'active_support/core_ext/class/attribute_accessors'
require
'monitor'
module
ActionDispatch
# :nodoc:
module
ActionDispatch
# :nodoc:
# Represents an HTTP response generated by a controller action. Use it to
# Represents an HTTP response generated by a controller action. Use it to
...
@@ -62,12 +63,17 @@ class Response
...
@@ -62,12 +63,17 @@ class Response
include
Rack
::
Response
::
Helpers
include
Rack
::
Response
::
Helpers
include
ActionDispatch
::
Http
::
Cache
::
Response
include
ActionDispatch
::
Http
::
Cache
::
Response
include
MonitorMixin
def
initialize
(
status
=
200
,
header
=
{},
body
=
[])
def
initialize
(
status
=
200
,
header
=
{},
body
=
[])
super
()
self
.
body
,
self
.
header
,
self
.
status
=
body
,
header
,
status
self
.
body
,
self
.
header
,
self
.
status
=
body
,
header
,
status
@sending_file
=
false
@sending_file
=
false
@blank
=
false
@blank
=
false
@cv
=
new_cond
@committed
=
false
if
content_type
=
self
[
CONTENT_TYPE
]
if
content_type
=
self
[
CONTENT_TYPE
]
type
,
charset
=
content_type
.
split
(
/;\s*charset=/
)
type
,
charset
=
content_type
.
split
(
/;\s*charset=/
)
...
@@ -80,6 +86,23 @@ def initialize(status = 200, header = {}, body = [])
...
@@ -80,6 +86,23 @@ def initialize(status = 200, header = {}, body = [])
yield
self
if
block_given?
yield
self
if
block_given?
end
end
def
await_commit
synchronize
do
@cv
.
wait_until
{
@committed
}
end
end
def
commit!
synchronize
do
@committed
=
true
@cv
.
broadcast
end
end
def
committed?
synchronize
{
@committed
}
end
def
status
=
(
status
)
def
status
=
(
status
)
@status
=
Rack
::
Utils
.
status_code
(
status
)
@status
=
Rack
::
Utils
.
status_code
(
status
)
end
end
...
...
actionpack/test/dispatch/response_test.rb
浏览文件 @
acb68484
...
@@ -5,6 +5,15 @@ def setup
...
@@ -5,6 +5,15 @@ def setup
@response
=
ActionDispatch
::
Response
.
new
@response
=
ActionDispatch
::
Response
.
new
end
end
def
test_can_wait_until_commit
t
=
Thread
.
new
{
assert
@response
.
await_commit
}
@response
.
commit!
assert
@response
.
committed?
t
.
join
end
def
test_response_body_encoding
def
test_response_body_encoding
body
=
[
"hello"
.
encode
(
'utf-8'
)]
body
=
[
"hello"
.
encode
(
'utf-8'
)]
response
=
ActionDispatch
::
Response
.
new
200
,
{},
body
response
=
ActionDispatch
::
Response
.
new
200
,
{},
body
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录