class Async::HTTP::Protocol::HTTP11

def read_response_body(request, status, headers)

def read_response_body(request, status, headers)
	# RFC 7230 3.3.3
	# 1.  Any response to a HEAD request and any response with a 1xx
	# (Informational), 204 (No Content), or 304 (Not Modified) status
	# code is always terminated by the first empty line after the
	# header fields, regardless of the header fields present in the
	# message, and thus cannot contain a message body.
	if request.head? or status == 204 or status == 304
		return nil
	end
	
	# 2.  Any 2xx (Successful) response to a CONNECT request implies that
	# the connection will become a tunnel immediately after the empty
	# line that concludes the header fields.  A client MUST ignore any
	# Content-Length or Transfer-Encoding header fields received in
	# such a message.
	if request.connect? and status == 200
		return Body::Remainder.new(@stream)
	end
	
	if body = read_body(headers)
		return body
	else
		# 7.  Otherwise, this is a response message without a declared message
		# body length, so the message body length is determined by the
		# number of octets received prior to the server closing the
		# connection.
		return Body::Remainder.new(@stream)
	end
end