lib/fastdfs-client/client_proxy.rb in fastdfs-client-1.3.0 vs lib/fastdfs-client/client_proxy.rb in fastdfs-client-1.4.0

- old
+ new

@@ -15,15 +15,17 @@ @port = port @socket = Socket.new(host, port, options[:socket]) end - def dispose(cmd, content_len, header = [], content = [], &block) + def dispose(cmd, header = [], content = [], &block) synchronize do - @socket.connection do - full_header = ProtoCommon.header_bytes(cmd, content_len) + header + @socket.connection do + contents = Array(content) + body_len = contents.map{|c| c.bytes.size }.inject(header.length){|sum, x| sum + x } + full_header = ProtoCommon.header_bytes(cmd, body_len).concat(header) @socket.write(cmd, full_header) - Array(content).each do |c| + contents.each do |c| @socket.write(cmd, c) end @socket.receive &block end end \ No newline at end of file