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

Yes, I plan to merge this after that fix.