class Puma::Client
def try_to_finish
def try_to_finish if env[CONTENT_LENGTH] && above_http_content_limit(env[CONTENT_LENGTH].to_i) @http_content_length_limit_exceeded = true end if @http_content_length_limit_exceeded @buffer = nil @body = EmptyBody set_ready return true end return read_body if in_data_phase data = nil begin data = @io.read_nonblock(CHUNK_SIZE) rescue IO::WaitReadable return false rescue EOFError # Swallow error, don't log rescue SystemCallError, IOError raise ConnectionError, "Connection error detected during read" end # No data means a closed socket unless data @buffer = nil set_ready raise EOFError end if @buffer @buffer << data else @buffer = data end return false unless try_to_parse_proxy_protocol @parsed_bytes = parser_execute if @parser.finished? && above_http_content_limit(@parser.body.bytesize) @http_content_length_limit_exceeded = true end if @parser.finished? setup_body elsif @parsed_bytes >= MAX_HEADER raise HttpParserError, "HEADER is longer than allowed, aborting client early." else false end end