Sets the Content-Length in to_a unless it is already set before
This commit is contained in:
parent
c15e8bdacb
commit
78121c6eea
|
@ -32,8 +32,8 @@ module Zero
|
||||||
#
|
#
|
||||||
def to_a()
|
def to_a()
|
||||||
# TODO Remove content length and body, on certain status codes
|
# TODO Remove content length and body, on certain status codes
|
||||||
# TODO Set content length, if not already set
|
# Set content length, if not already set
|
||||||
content_length
|
content_length unless header.has_key? 'Content-Length'
|
||||||
# TODO Set content type, if not already set
|
# TODO Set content type, if not already set
|
||||||
|
|
||||||
[status, header, body]
|
[status, header, body]
|
||||||
|
|
|
@ -20,11 +20,18 @@ describe Zero::Response do
|
||||||
|
|
||||||
it "returns the content length in the header" do
|
it "returns the content length in the header" do
|
||||||
subject.body = ['foobar']
|
subject.body = ['foobar']
|
||||||
|
|
||||||
value = subject.to_a
|
value = subject.to_a
|
||||||
|
|
||||||
value[1].should eq({'Content-Length' => 6}) # Headers
|
value[1].should eq({'Content-Length' => 6}) # Headers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not fix the Content-Length, if it's already set" do
|
||||||
|
subject.body = ['foobar']
|
||||||
|
subject.header = {'Content-Length' => 3}
|
||||||
|
value = subject.to_a
|
||||||
|
|
||||||
|
value[1].should eq({'Content-Length' => 3}) # Headers
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#status' do
|
describe '#status' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user