Method: Rack::Response#write

Defined in:
lib/rack/response.rb

#write(str) ⇒ Object

Append to body and update Content-Length.

NOTE: Do not mix #write and direct #body access!



94
95
96
97
98
99
100
101
# File 'lib/rack/response.rb', line 94

def write(str)
  s = str.to_s
  @length += Rack::Utils.bytesize(s) unless @chunked
  @writer.call s

  header["Content-Length"] = @length.to_s unless @chunked
  str
end