Index: src/wp-includes/class-wp.php
===================================================================
--- src/wp-includes/class-wp.php	(revision 53428)
+++ src/wp-includes/class-wp.php	(working copy)
@@ -769,8 +769,6 @@
 
 		$parsed = $this->parse_request( $query_args );
 
-		$this->send_headers();
-
 		if ( $parsed ) {
 			$this->query_posts();
 			$this->handle_404();
@@ -777,6 +775,8 @@
 			$this->register_globals();
 		}
 
+		$this->send_headers();
+
 		/**
 		 * Fires once the WordPress environment has been set up.
 		 *
