class HTTP::Response::Body
def to_s
-
(String)
- eagerly consume the entire body as a string
def to_s return @contents if @contents raise StateError, "body is being streamed" unless @streaming.nil? begin @streaming = false @contents = String.new("", :encoding => @encoding) while (chunk = @stream.readpartial) @contents << String.new(chunk, :encoding => @encoding) chunk = nil # deallocate string end rescue @contents = nil raise end @contents end