def get_body(&block)
begin
read_header if @state == :META
return nil if @state != :DATA
if @gzipped and @transparent_gzip_decompression
inflate_stream = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)
original_block = block
block = Proc.new { |buf|
original_block.call(inflate_stream.inflate(buf))
}
end
if @chunked
read_body_chunked(&block)
elsif @content_length
read_body_length(&block)
else
read_body_rest(&block)
end
rescue
close
raise
end
if eof?
if @next_connection
@state = :WAIT
else
close
end
end
nil
end