Compute response's Content-Length once

This commit is contained in:
Loic Nageleisen 2017-09-19 14:09:47 +02:00
parent 88d0824dc8
commit ea6406f4b8

View file

@ -186,7 +186,7 @@ module NanoServe
end end
def body=(value) def body=(value)
@body = value.tap { @content_length = body.bytes.count.to_s } @body = value.tap { @content_length = value.bytes.count.to_s }
end end
def to_s def to_s
@ -216,7 +216,7 @@ module NanoServe
end end
def content_length def content_length
@content_length ||= body.bytes.count.to_s @content_length || '0'
end end
def content_type def content_type