We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 48be8fa commit 238cfcfCopy full SHA for 238cfcf
src/HeaderUtil.php
@@ -84,4 +84,22 @@ public static function normalize(array $headers):array{
84
return $normalized;
85
}
86
87
+ /**
88
+ * Trims whitespace from the header values.
89
+ *
90
+ * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
91
92
+ * header-field = field-name ":" OWS field-value OWS
93
+ * OWS = *( SP / HTAB )
94
95
+ * @param string[] $values header values
96
97
+ * @return string[] Trimmed header values
98
99
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
100
+ */
101
+ public static function trimHeaderValues(array $values):array{
102
+ return array_map(fn(string $value):string => trim($value, " \t"), $values);
103
+ }
104
+
105
0 commit comments