Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a1bf2f96
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,发现更多精彩内容 >>
提交
a1bf2f96
编写于
12月 22, 2009
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AD::StatusCodes support is now part of rack
上级
17b60530
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
12 addition
and
46 deletion
+12
-46
actionpack/lib/action_controller/base.rb
actionpack/lib/action_controller/base.rb
+1
-1
actionpack/lib/action_controller/metal.rb
actionpack/lib/action_controller/metal.rb
+1
-1
actionpack/lib/action_controller/metal/redirecting.rb
actionpack/lib/action_controller/metal/redirecting.rb
+4
-4
actionpack/lib/action_dispatch.rb
actionpack/lib/action_dispatch.rb
+0
-1
actionpack/lib/action_dispatch/http/response.rb
actionpack/lib/action_dispatch/http/response.rb
+2
-2
actionpack/lib/action_dispatch/http/status_codes.rb
actionpack/lib/action_dispatch/http/status_codes.rb
+0
-33
actionpack/lib/action_dispatch/middleware/show_exceptions.rb
actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+1
-1
actionpack/lib/action_dispatch/testing/assertions/response.rb
...onpack/lib/action_dispatch/testing/assertions/response.rb
+1
-1
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+2
-2
未找到文件。
actionpack/lib/action_controller/base.rb
浏览文件 @
a1bf2f96
...
@@ -90,7 +90,7 @@ def _normalize_options(action = nil, options = {}, &blk)
...
@@ -90,7 +90,7 @@ def _normalize_options(action = nil, options = {}, &blk)
end
end
if
options
[
:status
]
if
options
[
:status
]
options
[
:status
]
=
ActionDispatch
::
StatusCodes
[
options
[
:status
]]
options
[
:status
]
=
Rack
::
Utils
.
status_code
(
options
[
:status
])
end
end
options
[
:update
]
=
blk
if
block_given?
options
[
:update
]
=
blk
if
block_given?
...
...
actionpack/lib/action_controller/metal.rb
浏览文件 @
a1bf2f96
...
@@ -69,7 +69,7 @@ def location=(url)
...
@@ -69,7 +69,7 @@ def location=(url)
end
end
def
status
=
(
status
)
def
status
=
(
status
)
@_status
=
ActionDispatch
::
StatusCodes
[
status
]
@_status
=
Rack
::
Utils
.
status_code
(
status
)
end
end
# :api: private
# :api: private
...
...
actionpack/lib/action_controller/metal/redirecting.rb
浏览文件 @
a1bf2f96
...
@@ -58,18 +58,18 @@ def redirect_to(options = {}, response_status = {}) #:doc:
...
@@ -58,18 +58,18 @@ def redirect_to(options = {}, response_status = {}) #:doc:
logger
.
info
(
"Redirected to
#{
location
}
"
)
if
logger
&&
logger
.
info?
logger
.
info
(
"Redirected to
#{
location
}
"
)
if
logger
&&
logger
.
info?
end
end
private
private
def
_extract_redirect_to_status
(
options
,
response_status
)
def
_extract_redirect_to_status
(
options
,
response_status
)
status
=
if
options
.
is_a?
(
Hash
)
&&
options
.
key?
(
:status
)
status
=
if
options
.
is_a?
(
Hash
)
&&
options
.
key?
(
:status
)
ActionDispatch
::
StatusCodes
[
options
.
delete
(
:status
)]
Rack
::
Utils
.
status_code
(
options
.
delete
(
:status
))
elsif
response_status
.
key?
(
:status
)
elsif
response_status
.
key?
(
:status
)
ActionDispatch
::
StatusCodes
[
response_status
[
:status
]]
Rack
::
Utils
.
status_code
(
response_status
[
:status
])
else
else
302
302
end
end
end
end
def
_compute_redirect_to_location
(
options
)
def
_compute_redirect_to_location
(
options
)
case
options
case
options
# The scheme name consist of a letter followed by any combination of
# The scheme name consist of a letter followed by any combination of
...
...
actionpack/lib/action_dispatch.rb
浏览文件 @
a1bf2f96
...
@@ -37,7 +37,6 @@ module ActionDispatch
...
@@ -37,7 +37,6 @@ module ActionDispatch
autoload_under
'http'
do
autoload_under
'http'
do
autoload
:Request
autoload
:Request
autoload
:Response
autoload
:Response
autoload
:StatusCodes
end
end
deferrable
do
deferrable
do
...
...
actionpack/lib/action_dispatch/http/response.rb
浏览文件 @
a1bf2f96
...
@@ -60,7 +60,7 @@ def cache_control
...
@@ -60,7 +60,7 @@ def cache_control
end
end
def
status
=
(
status
)
def
status
=
(
status
)
@status
=
ActionDispatch
::
StatusCodes
[
status
]
@status
=
Rack
::
Utils
.
status_code
(
status
)
end
end
# The response code of the request
# The response code of the request
...
@@ -74,7 +74,7 @@ def code
...
@@ -74,7 +74,7 @@ def code
end
end
def
message
def
message
StatusCodes
::
STATUS_CODES
[
@status
]
Rack
::
Utils
::
HTTP_
STATUS_CODES
[
@status
]
end
end
alias_method
:status_message
,
:message
alias_method
:status_message
,
:message
...
...
actionpack/lib/action_dispatch/http/status_codes.rb
已删除
100644 → 0
浏览文件 @
17b60530
require
'active_support/inflector'
module
ActionDispatch
module
StatusCodes
#:nodoc:
STATUS_CODES
=
Rack
::
Utils
::
HTTP_STATUS_CODES
.
merge
({
102
=>
"Processing"
,
207
=>
"Multi-Status"
,
226
=>
"IM Used"
,
422
=>
"Unprocessable Entity"
,
423
=>
"Locked"
,
424
=>
"Failed Dependency"
,
426
=>
"Upgrade Required"
,
507
=>
"Insufficient Storage"
,
510
=>
"Not Extended"
}).
freeze
def
self
.
[]
(
status
)
if
status
.
is_a?
(
Symbol
)
SYMBOL_TO_STATUS_CODE
[
status
]
||
500
else
status
.
to_i
end
end
# Provides a symbol-to-fixnum lookup for converting a symbol (like
# :created or :not_implemented) into its corresponding HTTP status
# code (like 200 or 501).
SYMBOL_TO_STATUS_CODE
=
STATUS_CODES
.
inject
({})
{
|
hash
,
(
code
,
message
)
|
hash
[
ActiveSupport
::
Inflector
.
underscore
(
message
.
gsub
(
/ /
,
""
)).
to_sym
]
=
code
hash
}.
freeze
end
end
actionpack/lib/action_dispatch/middleware/show_exceptions.rb
浏览文件 @
a1bf2f96
...
@@ -101,7 +101,7 @@ def local_request?(request)
...
@@ -101,7 +101,7 @@ def local_request?(request)
end
end
def
status_code
(
exception
)
def
status_code
(
exception
)
ActionDispatch
::
StatusCodes
::
SYMBOL_TO_STATUS_CODE
[
@@rescue_responses
[
exception
.
class
.
name
]]
Rack
::
Utils
.
status_code
(
@@rescue_responses
[
exception
.
class
.
name
])
end
end
def
render
(
status
,
body
)
def
render
(
status
,
body
)
...
...
actionpack/lib/action_dispatch/testing/assertions/response.rb
浏览文件 @
a1bf2f96
...
@@ -28,7 +28,7 @@ def assert_response(type, message = nil)
...
@@ -28,7 +28,7 @@ def assert_response(type, message = nil)
assert_block
(
""
)
{
true
}
# to count the assertion
assert_block
(
""
)
{
true
}
# to count the assertion
elsif
type
.
is_a?
(
Fixnum
)
&&
@response
.
response_code
==
type
elsif
type
.
is_a?
(
Fixnum
)
&&
@response
.
response_code
==
type
assert_block
(
""
)
{
true
}
# to count the assertion
assert_block
(
""
)
{
true
}
# to count the assertion
elsif
type
.
is_a?
(
Symbol
)
&&
@response
.
response_code
==
ActionDispatch
::
StatusCode
s
::
SYMBOL_TO_STATUS_CODE
[
type
]
elsif
type
.
is_a?
(
Symbol
)
&&
@response
.
response_code
==
Rack
::
Util
s
::
SYMBOL_TO_STATUS_CODE
[
type
]
assert_block
(
""
)
{
true
}
# to count the assertion
assert_block
(
""
)
{
true
}
# to count the assertion
else
else
assert_block
(
build_message
(
message
,
"Expected response to be a <?>, but was <?>"
,
type
,
@response
.
response_code
))
{
false
}
assert_block
(
build_message
(
message
,
"Expected response to be a <?>, but was <?>"
,
type
,
@response
.
response_code
))
{
false
}
...
...
actionpack/test/controller/render_test.rb
浏览文件 @
a1bf2f96
...
@@ -1125,7 +1125,7 @@ def test_head_with_symbolic_status
...
@@ -1125,7 +1125,7 @@ def test_head_with_symbolic_status
assert
!
@response
.
headers
.
include?
(
'Content-Length'
)
assert
!
@response
.
headers
.
include?
(
'Content-Length'
)
assert_response
:no_content
assert_response
:no_content
ActionDispatch
::
StatusCode
s
::
SYMBOL_TO_STATUS_CODE
.
each
do
|
status
,
code
|
Rack
::
Util
s
::
SYMBOL_TO_STATUS_CODE
.
each
do
|
status
,
code
|
get
:head_with_symbolic_status
,
:status
=>
status
.
to_s
get
:head_with_symbolic_status
,
:status
=>
status
.
to_s
assert_equal
code
,
@response
.
response_code
assert_equal
code
,
@response
.
response_code
assert_response
status
assert_response
status
...
@@ -1133,7 +1133,7 @@ def test_head_with_symbolic_status
...
@@ -1133,7 +1133,7 @@ def test_head_with_symbolic_status
end
end
def
test_head_with_integer_status
def
test_head_with_integer_status
ActionDispatch
::
StatusCodes
::
STATUS_CODES
.
each
do
|
code
,
message
|
Rack
::
Utils
::
HTTP_
STATUS_CODES
.
each
do
|
code
,
message
|
get
:head_with_integer_status
,
:status
=>
code
.
to_s
get
:head_with_integer_status
,
:status
=>
code
.
to_s
assert_equal
message
,
@response
.
message
assert_equal
message
,
@response
.
message
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录