From d34f4b0c0f60a33ae211ca964de7cd08da7c7747 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 29 Sep 2021 10:50:30 +0100 Subject: [PATCH] Don't count CR or LF as whitespace when trimming whitespace from header values (#306) Motivation: The OWS rule from the HTTP semantics draft only considers 'SP' and 'HTAB' to be whitespace. We also (unnecessarily) consider CR and LF to be whitespace. Modifications: - Remove CR and LF from the characters we consider to be whitespace - Update tests Result: We no longer consider CR or LF to be whitespace when trimming whitespace when producing the canonical form of header values. --- Sources/NIOHPACK/HPACKHeader.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sources/NIOHPACK/HPACKHeader.swift b/Sources/NIOHPACK/HPACKHeader.swift index ef5211a..dfa9e35 100644 --- a/Sources/NIOHPACK/HPACKHeader.swift +++ b/Sources/NIOHPACK/HPACKHeader.swift @@ -472,9 +472,7 @@ internal extension UTF8.CodeUnit { var isASCIIWhitespace: Bool { switch self { case UInt8(ascii: " "), - UInt8(ascii: "\t"), - UInt8(ascii: "\r"), - UInt8(ascii: "\n"): + UInt8(ascii: "\t"): return true default: return false