File tree 3 files changed +17
-3
lines changed
src/Symfony/Component/HttpFoundation
3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -212,7 +212,7 @@ class Response
212
212
];
213
213
214
214
/**
215
- * Tracks headers already sent in informational responses
215
+ * Tracks headers already sent in informational responses.
216
216
*/
217
217
private array $ sentHeaders ;
218
218
Original file line number Diff line number Diff line change @@ -69,9 +69,12 @@ public function sendHeaders(/* ?int $statusCode = null */): static
69
69
return $ this ;
70
70
}
71
71
72
- $ this ->headersSent = true ;
72
+ $ statusCode = \func_num_args () > 0 ? func_get_arg (0 ) : null ;
73
+ if ($ statusCode < 100 || $ statusCode >= 200 ) {
74
+ $ this ->headersSent = true ;
75
+ }
73
76
74
- return parent ::sendHeaders (... \func_get_args () );
77
+ return parent ::sendHeaders ($ statusCode );
75
78
}
76
79
77
80
/**
Original file line number Diff line number Diff line change @@ -124,4 +124,15 @@ public function testSetNotModified()
124
124
$ string = ob_get_clean ();
125
125
$ this ->assertEmpty ($ string );
126
126
}
127
+
128
+ public function testSendInformationalResponse ()
129
+ {
130
+ $ response = new StreamedResponse ();
131
+ $ response ->sendHeaders (103 );
132
+
133
+ // Informational responses must not override the main status code
134
+ $ this ->assertSame (200 , $ response ->getStatusCode ());
135
+
136
+ $ response ->sendHeaders ();
137
+ }
127
138
}
You can’t perform that action at this time.
0 commit comments