Sets Content-Length to body string length
It joins the body array to a string and sets the Content-Length header to its length.
This commit is contained in:
parent
22cf93d002
commit
b4e56c6868
|
@ -42,7 +42,7 @@ module Zero
|
|||
# Also creates one, if it does not exists
|
||||
#
|
||||
def content_length
|
||||
header['Content-Length'] = 0
|
||||
header['Content-Length'] = body.join.length
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -53,6 +53,13 @@ describe Zero::Response do
|
|||
|
||||
subject.header['Content-Length'].should eq(0)
|
||||
end
|
||||
|
||||
it "sets the content_length to the size of the message body" do
|
||||
subject.body = ['foo', 'bar']
|
||||
subject.content_length
|
||||
|
||||
subject.header['Content-Length'].should eq(6)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue