Backport fixes about #7774 to 3-2-stable

Fix ActionDispatch::Request#formats when HTTP_ACCEPT header is an empty
string.
Merge pull request #9543 from maximerety/backport_fix_7774

Backported #7774 to 3-2-stable