@@ -924,8 +924,8 @@ void shouldAttemptToResetResponseBufferIfCommitted() throws Exception {
924
924
assertThat (response .getHeader ("Test-Header" )).isEqualTo ("spring" );
925
925
}
926
926
927
- @ Test
928
- void shouldResetContentTypeIfNotCommitted () throws Exception {
927
+ @ Test // gh-34366, gh-35116
928
+ void shouldResetContentHeadersIfNotCommitted () throws Exception {
929
929
StaticWebApplicationContext context = new StaticWebApplicationContext ();
930
930
context .setServletContext (getServletContext ());
931
931
context .registerSingleton ("/error" , ErrorController .class );
@@ -934,11 +934,15 @@ void shouldResetContentTypeIfNotCommitted() throws Exception {
934
934
935
935
MockHttpServletRequest request = new MockHttpServletRequest (getServletContext (), "GET" , "/error" );
936
936
MockHttpServletResponse response = new MockHttpServletResponse ();
937
- assertThatThrownBy (() -> servlet .service (request , response )).isInstanceOf (ServletException .class )
937
+
938
+ assertThatThrownBy (() -> servlet .service (request , response ))
939
+ .isInstanceOf (ServletException .class )
938
940
.hasCauseInstanceOf (IllegalArgumentException .class );
941
+
939
942
assertThat (response .getContentAsByteArray ()).isEmpty ();
940
943
assertThat (response .getStatus ()).isEqualTo (400 );
941
944
assertThat (response .getHeaderNames ()).doesNotContain (HttpHeaders .CONTENT_TYPE );
945
+ assertThat (response .getHeaderNames ()).doesNotContain (HttpHeaders .CONTENT_DISPOSITION );
942
946
}
943
947
944
948
@@ -994,6 +998,7 @@ public ModelAndView handleRequest(HttpServletRequest request, HttpServletRespons
994
998
response .setStatus (400 );
995
999
response .setHeader ("Test-Header" , "spring" );
996
1000
response .addHeader ("Content-Type" , "application/json" );
1001
+ response .addHeader ("Content-Disposition" , "attachment; filename=\" report.txt\" " );
997
1002
if (request .getAttribute ("commit" ) != null ) {
998
1003
response .flushBuffer ();
999
1004
}
0 commit comments