0
0
Fork 0

Sets Content-Length to body string bytesize

Sets the Conten-Length to the bytesize of the joined body to cover UTF-8
This commit is contained in:
Stormwind 2012-11-23 18:06:53 +01:00
parent b4e56c6868
commit a2e6c299cd
2 changed files with 9 additions and 1 deletions

View File

@ -42,7 +42,7 @@ module Zero
# Also creates one, if it does not exists
#
def content_length
header['Content-Length'] = body.join.length
header['Content-Length'] = body.join.bytesize
end
end

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
require 'spec_helper'
describe Zero::Response do
@ -60,6 +61,13 @@ describe Zero::Response do
subject.header['Content-Length'].should eq(6)
end
it "sets the content_length to the bytesize of the message body" do
subject.body = ['föö', 'bär']
subject.content_length
subject.header['Content-Length'].should eq(9)
end
end
end