0
0
Fork 0

content_length sets the Content-Length to 0

The method content_length creates a header named Content-Length and sets
its value to 0.
This commit is contained in:
Stormwind 2012-11-23 17:43:39 +01:00
parent 2b79c3e840
commit 963adb8ddc
2 changed files with 18 additions and 0 deletions

View File

@ -38,5 +38,12 @@ module Zero
[@status, @header, @body]
end
# Sets the content length header to the current length of the body
# Also creates one, if it does not exists
#
def content_length
header['Content-Length'] = 0
end
end
end

View File

@ -16,6 +16,9 @@ describe Zero::Response do
value[1].should eq({}) # Headers
value[2].should eq([]) # Body
end
it "returns the content length in the header" do
end
end
describe '#status' do
@ -44,4 +47,12 @@ describe Zero::Response do
end
end
describe '#content_length' do
it "sets the content_length to 0, if there is no content" do
subject.content_length
subject.header['Content-Length'].should eq(0)
end
end
end