Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
97988829
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,发现更多精彩内容 >>
提交
97988829
编写于
4月 28, 2016
作者:
G
Guillermo Iguaran
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #24781 from maclover7/rm-env
Remove last uses of `
@env
[]` and `
@env
[]=`
上级
03b62b84
e0b5a773
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
12 deletion
+39
-12
actionpack/lib/action_dispatch/http/mime_negotiation.rb
actionpack/lib/action_dispatch/http/mime_negotiation.rb
+1
-1
actionpack/lib/action_dispatch/testing/test_request.rb
actionpack/lib/action_dispatch/testing/test_request.rb
+11
-11
actionpack/test/dispatch/test_request_test.rb
actionpack/test/dispatch/test_request_test.rb
+27
-0
未找到文件。
actionpack/lib/action_dispatch/http/mime_negotiation.rb
浏览文件 @
97988829
...
...
@@ -164,7 +164,7 @@ def use_accept_header
end
def
format_from_path_extension
path
=
@env
[
'action_dispatch.original_path'
]
||
@env
[
'PATH_INFO'
]
path
=
get_header
(
'action_dispatch.original_path'
)
||
get_header
(
'PATH_INFO'
)
if
match
=
path
&&
path
.
match
(
/\.(\w+)\z/
)
Mime
[
match
.
captures
.
first
]
end
...
...
actionpack/lib/action_dispatch/testing/test_request.rb
浏览文件 @
97988829
...
...
@@ -22,23 +22,23 @@ def self.default_env
private_class_method
:default_env
def
request_method
=
(
method
)
@env
[
'REQUEST_METHOD'
]
=
method
.
to_s
.
upcase
set_header
(
'REQUEST_METHOD'
,
method
.
to_s
.
upcase
)
end
def
host
=
(
host
)
@env
[
'HTTP_HOST'
]
=
host
set_header
(
'HTTP_HOST'
,
host
)
end
def
port
=
(
number
)
@env
[
'SERVER_PORT'
]
=
number
.
to_i
set_header
(
'SERVER_PORT'
,
number
.
to_i
)
end
def
request_uri
=
(
uri
)
@env
[
'REQUEST_URI'
]
=
uri
set_header
(
'REQUEST_URI'
,
uri
)
end
def
path
=
(
path
)
@env
[
'PATH_INFO'
]
=
path
set_header
(
'PATH_INFO'
,
path
)
end
def
action
=
(
action_name
)
...
...
@@ -46,24 +46,24 @@ def action=(action_name)
end
def
if_modified_since
=
(
last_modified
)
@env
[
'HTTP_IF_MODIFIED_SINCE'
]
=
last_modified
set_header
(
'HTTP_IF_MODIFIED_SINCE'
,
last_modified
)
end
def
if_none_match
=
(
etag
)
@env
[
'HTTP_IF_NONE_MATCH'
]
=
etag
set_header
(
'HTTP_IF_NONE_MATCH'
,
etag
)
end
def
remote_addr
=
(
addr
)
@env
[
'REMOTE_ADDR'
]
=
addr
set_header
(
'REMOTE_ADDR'
,
addr
)
end
def
user_agent
=
(
user_agent
)
@env
[
'HTTP_USER_AGENT'
]
=
user_agent
set_header
(
'HTTP_USER_AGENT'
,
user_agent
)
end
def
accept
=
(
mime_types
)
@env
.
delete
(
'action_dispatch.request.accepts'
)
@env
[
'HTTP_ACCEPT'
]
=
Array
(
mime_types
).
collect
(
&
:to_s
).
join
(
","
)
delete_header
(
'action_dispatch.request.accepts'
)
set_header
(
'HTTP_ACCEPT'
,
Array
(
mime_types
).
collect
(
&
:to_s
).
join
(
","
)
)
end
end
end
actionpack/test/dispatch/test_request_test.rb
浏览文件 @
97988829
...
...
@@ -88,6 +88,33 @@ class TestRequestTest < ActiveSupport::TestCase
assert_equal
'GoogleBot'
,
req
.
user_agent
end
test
"setter methods"
do
req
=
ActionDispatch
::
TestRequest
.
create
({})
get
=
'GET'
[
'request_method='
,
'host='
,
'request_uri='
,
'path='
,
'if_modified_since='
,
'if_none_match='
,
'remote_addr='
,
'user_agent='
,
'accept='
].
each
do
|
method
|
req
.
send
(
method
,
get
)
end
req
.
port
=
8080
req
.
accept
=
'hello goodbye'
assert_equal
(
get
,
req
.
get_header
(
'REQUEST_METHOD'
))
assert_equal
(
get
,
req
.
get_header
(
'HTTP_HOST'
))
assert_equal
(
8080
,
req
.
get_header
(
'SERVER_PORT'
))
assert_equal
(
get
,
req
.
get_header
(
'REQUEST_URI'
))
assert_equal
(
get
,
req
.
get_header
(
'PATH_INFO'
))
assert_equal
(
get
,
req
.
get_header
(
'HTTP_IF_MODIFIED_SINCE'
))
assert_equal
(
get
,
req
.
get_header
(
'HTTP_IF_NONE_MATCH'
))
assert_equal
(
get
,
req
.
get_header
(
'REMOTE_ADDR'
))
assert_equal
(
get
,
req
.
get_header
(
'HTTP_USER_AGENT'
))
assert_nil
(
req
.
get_header
(
'action_dispatch.request.accepts'
))
assert_equal
(
'hello goodbye'
,
req
.
get_header
(
'HTTP_ACCEPT'
))
end
private
def
assert_cookies
(
expected
,
cookie_jar
)
assert_equal
(
expected
,
cookie_jar
.
instance_variable_get
(
"@cookies"
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录