http_file: do not reopen opened file (on retry)
[ruby-mogilefs-client.git] / lib / mogilefs / chunker.rb
blob27ff74352185b2dc418204e10c4fac7dc14c0205
1 # -*- encoding: binary -*-
2 class MogileFS::Chunker
3   CRLF = "\r\n"
4   attr_reader :io
6   def initialize(io)
7     @io = io
8   end
10   def write(buf)
11     rv = buf.bytesize
12     @io.write("#{rv.to_s(16)}\r\n")
13     @io.write(buf)
14     @io.write(CRLF)
15     rv
16   end
18   def flush
19     @io.write("0\r\n\r\n")
20   end
21 end