Added a test to verify headers set by default middleware; refs #23939.

Very clever! I figured we were going to have to do something uglier to get at the list of default middlewares, but this works well, and as long as it runs on at least one supported Python version it should alert us to an issue; headers shouldn't ever vary between Python versions.