File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,21 @@ protected function removeHeaders() : static
243243 return $ this ;
244244 }
245245
246+ /**
247+ * Remove headers by names.
248+ *
249+ * @param array<string> $names
250+ *
251+ * @return static
252+ */
253+ protected function removeHeadersByNames (array $ names ) : static
254+ {
255+ foreach ($ names as $ name ) {
256+ $ this ->removeHeader ($ name );
257+ }
258+ return $ this ;
259+ }
260+
246261 /**
247262 * Say if the Message has a Cookie.
248263 *
Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ public function removeHeaders() : static
4444 return parent ::removeHeaders ();
4545 }
4646
47+ public function removeHeadersByNames (array $ names ) : static
48+ {
49+ return parent ::removeHeadersByNames ($ names );
50+ }
51+
4752 public function setBody (?string $ body ) : static
4853 {
4954 return parent ::setBody ($ body );
Original file line number Diff line number Diff line change @@ -97,6 +97,24 @@ public function testHeaders() : void
9797 );
9898 $ this ->message ->removeHeaders ();
9999 self ::assertSame ([], $ this ->message ->getHeaders ());
100+ $ this ->message ->setHeaders ([
101+ 'content-type ' => 'application/json ' ,
102+ 'allow ' => '* ' ,
103+ ]);
104+ self ::assertSame (
105+ [
106+ 'content-type ' => 'application/json ' ,
107+ 'allow ' => '* ' ,
108+ ],
109+ $ this ->message ->getHeaders ()
110+ );
111+ $ this ->message ->removeHeadersByNames (['content-type ' ]);
112+ self ::assertSame (
113+ [
114+ 'allow ' => '* ' ,
115+ ],
116+ $ this ->message ->getHeaders ()
117+ );
100118 }
101119
102120 public function testHeaderLine () : void
You can’t perform that action at this time.
0 commit comments