Context: #17122 (comment)
The code can likely be simplified a bit now that only Content-Types of text/plain are allowed.
We may also want to enforce this requirement in the type checker, rather than a runtime check, to reduce the chance of this check accidentally being removed in the future, and other code assuming it is there.