Skip to content

Commit 238cfcf

Browse files
committed
:octocat:
1 parent 48be8fa commit 238cfcf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/HeaderUtil.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,22 @@ public static function normalize(array $headers):array{
8484
return $normalized;
8585
}
8686

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+
87105
}

0 commit comments

Comments
 (0)