diff --git a/lib/puma/io_buffer.rb b/lib/puma/io_buffer.rb new file mode 100644 index 00000000..a7c4cbac --- /dev/null +++ b/lib/puma/io_buffer.rb @@ -0,0 +1,33 @@ +module Puma + class IOBuffer + def initialize + @buf = "" + end + + def reset + @buf = "" + end + + def <<(str) + @buf << str + end + + def append(*strs) + strs.each { |s| @buf << s } + end + + def to_s + @buf + end + + alias_method :to_str, :to_s + + def used + @buf.size + end + + def capacity + @buf.size + end + end +end diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 5a3e7274..90bd4959 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -14,6 +14,10 @@ require 'puma/accept_nonblock' require 'puma/puma_http11' +unless Puma.const_defined? "IOBuffer" + require 'puma/io_buffer' +end + require 'socket' module Puma