# File lib/rfuzz/client.rb, line 286
286:     def read_chunked_encoding(resp, sock, parser)
287:       out = StringIO.new
288:       input = StringIO.new(resp.http_body)
289: 
290:       # read from the http body first, then continue at the socket
291:       status, result = read_chunks(input, out, parser)
292: 
293:       case status
294:       when :incomplete_trailer
295:         if result.nil?
296:           sock.read(2)
297:         else
298:           sock.read((result.length - 2).abs)
299:         end
300:       when :incomplete_body
301:         out.write(sock.read(result))  # read the remaining
302:         sock.read(2)
303:       when :incomplete_header
304:         # push what we read back onto the socket, but backwards
305:         result.reverse!
306:         result.each_byte {|b| sock.ungetc(b) }
307:       when :finished
308:         # all done, get out
309:         out.rewind; return out.read
310:       when :eof_error
311:         # read everything we could, ignore
312:       end
313: 
314:       # then continue reading them from the socket
315:       status, result = read_chunks(sock, out, parser)
316: 
317:       # and now the http_body is the chunk
318:       out.rewind; return out.read
319:     end