@@ -898,8 +898,8 @@ void shouldAttemptToResetResponseBufferIfCommitted() throws Exception {
898
898
assertThat (response .getHeader ("Test-Header" )).isEqualTo ("spring" );
899
899
}
900
900
901
- @ Test
902
- void shouldResetContentTypeIfNotCommitted () throws Exception {
901
+ @ Test // gh-34366, gh-35116
902
+ void shouldResetContentHeadersIfNotCommitted () throws Exception {
903
903
StaticWebApplicationContext context = new StaticWebApplicationContext ();
904
904
context .setServletContext (getServletContext ());
905
905
context .registerSingleton ("/error" , ErrorController .class );
@@ -908,11 +908,15 @@ void shouldResetContentTypeIfNotCommitted() throws Exception {
908
908
909
909
MockHttpServletRequest request = new MockHttpServletRequest (getServletContext (), "GET" , "/error" );
910
910
MockHttpServletResponse response = new MockHttpServletResponse ();
911
- assertThatThrownBy (() -> servlet .service (request , response )).isInstanceOf (ServletException .class )
911
+
912
+ assertThatThrownBy (() -> servlet .service (request , response ))
913
+ .isInstanceOf (ServletException .class )
912
914
.hasCauseInstanceOf (IllegalArgumentException .class );
915
+
913
916
assertThat (response .getContentAsByteArray ()).isEmpty ();
914
917
assertThat (response .getStatus ()).isEqualTo (400 );
915
918
assertThat (response .getHeaderNames ()).doesNotContain (HttpHeaders .CONTENT_TYPE );
919
+ assertThat (response .getHeaderNames ()).doesNotContain (HttpHeaders .CONTENT_DISPOSITION );
916
920
}
917
921
918
922
@@ -968,6 +972,7 @@ public ModelAndView handleRequest(HttpServletRequest request, HttpServletRespons
968
972
response .setStatus (400 );
969
973
response .setHeader ("Test-Header" , "spring" );
970
974
response .addHeader ("Content-Type" , "application/json" );
975
+ response .addHeader ("Content-Disposition" , "attachment; filename=\" report.txt\" " );
971
976
if (request .getAttribute ("commit" ) != null ) {
972
977
response .flushBuffer ();
973
978
}
0 commit comments