Backport fixes about #7774 to 3-2-stable

Fix ActionDispatch::Request#formats when HTTP_ACCEPT header is an empty
string.