Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
07441488
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,体验更适合开发者的 AI 搜索 >>
提交
07441488
编写于
1月 07, 2009
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove Content-Length header from :no_content responses
上级
48963a55
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
4 deletion
+12
-4
actionpack/lib/action_controller/response.rb
actionpack/lib/action_controller/response.rb
+6
-3
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+6
-1
未找到文件。
actionpack/lib/action_controller/response.rb
浏览文件 @
07441488
...
...
@@ -231,10 +231,13 @@ def convert_content_type!
# Don't set the Content-Length for block-based bodies as that would mean
# reading it all into memory. Not nice for, say, a 2GB streaming file.
def
set_content_length!
unless
body
.
respond_to?
(
:call
)
||
(
status
&&
status
.
to_s
[
0
..
2
]
==
'304'
)
self
.
headers
[
"Content-Length"
]
||=
body
.
size
if
status
&&
status
.
to_s
[
0
..
2
]
==
'204'
headers
.
delete
(
'Content-Length'
)
elsif
length
=
headers
[
'Content-Length'
]
headers
[
'Content-Length'
]
=
length
.
to_s
elsif
!
body
.
respond_to?
(
:call
)
&&
(
!
status
||
status
.
to_s
[
0
..
2
]
!=
'304'
)
headers
[
"Content-Length"
]
=
body
.
size
.
to_s
end
headers
[
"Content-Length"
]
=
headers
[
"Content-Length"
].
to_s
if
headers
[
"Content-Length"
]
end
def
convert_language!
...
...
actionpack/test/controller/render_test.rb
浏览文件 @
07441488
...
...
@@ -1218,6 +1218,11 @@ def test_head_with_symbolic_status
assert_equal
"404 Not Found"
,
@response
.
status
assert_response
:not_found
get
:head_with_symbolic_status
,
:status
=>
"no_content"
assert_equal
"204 No Content"
,
@response
.
status
assert
!
@response
.
headers
.
include?
(
'Content-Length'
)
assert_response
:no_content
ActionController
::
StatusCodes
::
SYMBOL_TO_STATUS_CODE
.
each
do
|
status
,
code
|
get
:head_with_symbolic_status
,
:status
=>
status
.
to_s
assert_equal
code
,
@response
.
response_code
...
...
@@ -1470,7 +1475,7 @@ def test_render_against_etag_request_should_304_when_match
def
test_render_against_etag_request_should_have_no_content_length_when_match
@request
.
if_none_match
=
etag_for
(
"hello david"
)
get
:render_hello_world_from_variable
assert
!
@response
.
headers
.
has_key?
(
"Content-Length"
)
assert
!
@response
.
headers
.
has_key?
(
"Content-Length"
)
,
@response
.
headers
[
'Content-Length'
]
end
def
test_render_against_etag_request_should_200_when_no_match
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录