72: def stream_one_chunk
73: loop {
74: if @position < @size
75: if @connection.get_outbound_data_size > BackpressureLevel
76: EventMachine::next_tick {stream_one_chunk}
77: break
78: else
79: len = @size - @position
80: len = ChunkSize if (len > ChunkSize)
81:
82:
83: @connection.send_data( "#{len.to_s(16)}\r\n" ) if @http_chunks
84: @connection.send_data( @mapping.get_chunk( @position, len ))
85: @connection.send_data("\r\n") if @http_chunks
86:
87: @position += len
88: end
89: else
90: @connection.send_data "0\r\n\r\n" if @http_chunks
91: @mapping.close
92: succeed
93: break
94: end
95: }
96: end