Module: M2R::Response::ContentLength

Included in:
M2R::Reply
Defined in:
lib/m2r/response/content_length.rb

Overview

Adds Content-Length header based on body size This is mostly required when you use bare Response class without any framework on top of it. HTTP clients require such header when there is body in response. Otherwise they hang out.

Instance Method Summary collapse

Instance Method Details

#headers(value = GETTER) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/m2r/response/content_length.rb', line 11

def headers(value = GETTER)
  if value == GETTER
    h = super
    h['Content-Length'] ||= body.bytesize
    h
  else
    super
  end
end