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:
parent
b4e56c6868
commit
a2e6c299cd
@ -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
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user