Delete Content-Length. Conten-Type and body on status 304
This commit is contained in:
parent
285b7f2214
commit
5c45e1e20b
@ -31,8 +31,8 @@ module Zero
|
|||||||
# @return [Array]
|
# @return [Array]
|
||||||
#
|
#
|
||||||
def to_a
|
def to_a
|
||||||
# TODO Remove content length and body, on certain status codes
|
# Remove content length and body, on status 204 and 304
|
||||||
if status == 204
|
if status == 204 or status == 304
|
||||||
header.delete('Content-Length')
|
header.delete('Content-Length')
|
||||||
header.delete('Content-Type')
|
header.delete('Content-Type')
|
||||||
self.body = []
|
self.body = []
|
||||||
|
@ -56,6 +56,17 @@ describe Zero::Response do
|
|||||||
|
|
||||||
value[1].should eq({}) # Headers
|
value[1].should eq({}) # Headers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "removes Content-Type, Content-Length and body on status code 304" do
|
||||||
|
subject.body.push '"foobar"'
|
||||||
|
subject.content_type 'application/json'
|
||||||
|
subject.header['Content-Length'] = 8
|
||||||
|
|
||||||
|
subject.status = 304
|
||||||
|
value = subject.to_a
|
||||||
|
|
||||||
|
value[1].should eq({}) # Headers
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#status' do
|
describe '#status' do
|
||||||
|
Loading…
Reference in New Issue
Block a user