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