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