Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Status code 205 also has no body, thanks @lgierth.

  • Loading branch information...
commit b097a5ec26be70904121ec3712807fbea8215ad3 1 parent fa1027b
@seancribbs seancribbs authored
View
2  lib/webmachine/decision/helpers.rb
@@ -106,7 +106,7 @@ def ensure_content_length
case
when response.headers['Transfer-Encoding']
return
- when [204, 304].include?(response.code)
+ when [204, 205, 304].include?(response.code)
response.headers.delete 'Content-Length'
when has_response_body?
set_content_length
View
12 spec/webmachine/decision/helpers_spec.rb
@@ -46,8 +46,8 @@ def accept_doc; result; end
end
end
- context "setting the Content-Length header when responding" do
- [204, 304].each do |code|
+ context "setting the Content-Length header when responding" do
+ [204, 205, 304].each do |code|
it "removes the header for entity-less response code #{code}" do
response.headers['Content-Length'] = '0'
response.body = nil
@@ -57,9 +57,9 @@ def accept_doc; result; end
end
(200..599).each do |code|
- # 204 and 304 have no bodies, 404 is set to a default non-zero
- # response by Webmachine
- next if code == 204 || code == 304 || code == 404
+ # 204, 205 and 304 have no bodies, 404 is set to a default
+ # non-zero response by Webmachine
+ next if [204, 205, 304, 404].include? code
it "adds the header for response code #{code} that should include an entity but has an empty body" do
response.code = code
@@ -70,7 +70,7 @@ def accept_doc; result; end
end
(200..599).each do |code|
- next if code == 204 || code == 304
+ next if [204, 205, 304].include? code
it "does not add the header when Transfer-Encoding is set on code #{code}" do
response.headers['Transfer-Encoding'] = 'chunked'

0 comments on commit b097a5e

Please sign in to comment.
Something went wrong with that request. Please try again.