File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,17 @@ public static function trimValues(iterable $values):iterable{
108108 }
109109
110110 /**
111- * Normalizes a header name, e.g. "conTENT - lenGTh" -> "Content-Length"
111+ * Normalizes a header name, e.g. "con TENT - lenGTh" -> "Content-Length"
112112 */
113113 public static function normalizeHeaderName (string $ name ):string {
114- return implode ('- ' , array_map (fn (string $ v ):string => ucfirst (strtolower (trim ($ v ))), explode ('- ' , $ name )));
114+ $ parts = explode ('- ' , $ name );
115+
116+ foreach ($ parts as &$ part ){
117+ // we'll remove any spaces in the name part, e.g. "con tent" -> "content"
118+ $ part = ucfirst (strtolower (str_replace (' ' , '' , trim ($ part ))));
119+ }
120+
121+ return implode ('- ' , $ parts );
115122 }
116123
117124}
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public static function headerDataProvider():array{
3535 'invalid: what ' => [['what ' ], []],
3636 'empty value ' => [['empty-value ' => '' ], ['Empty-Value ' => '' ]],
3737 'null value ' => [['null-value ' => null ], ['Null-Value ' => '' ]],
38+ 'space in name ' => [['space name - header ' => 'nope ' ], ['Spacename-Header ' => 'nope ' ]],
3839 ];
3940 }
4041
You can’t perform that action at this time.
0 commit comments