Fix bad logic in xhr that tries to avoid double-setting Content-Type

Fixes #18237.

(cherry picked from commit 33e102dfe99c201efdb817931167261cf4985e9b)