@@ -24,7 +24,6 @@ import pekko.http.scaladsl.model._
2424import pekko .http .scaladsl .model .headers .`Tls-Session-Info`
2525import pekko .http .scaladsl .settings .ServerSettings
2626import pekko .stream .Attributes
27- import pekko .util .ByteString
2827import pekko .util .OptionVal
2928
3029import scala .annotation .tailrec
@@ -191,13 +190,12 @@ private[http2] object RequestParsing {
191190 }
192191
193192 private [http2] def parseHeaderPair (httpHeaderParser : HttpHeaderParser , name : String , value : String ): HttpHeader = {
194- // FIXME: later modify by adding HttpHeaderParser.parseHttp2Header that would use (name, value) pair directly
195- // or use a separate, simpler, parser for Http2
196- // The odd-looking 'x' below is a by-product of how current parser and HTTP/1.1 work.
197- // Without '\r\n\x' (x being any additional byte) parsing will fail. See HttpHeaderParserSpec for examples.
198- val concHeaderLine = name + " : " + value + " \r\n x"
199- httpHeaderParser.parseHeaderLine(ByteString (concHeaderLine))()
200- httpHeaderParser.resultHeader
193+ import HttpHeader .ParsingResult
194+ HttpHeader .parse(name, value, httpHeaderParser.settings) match {
195+ case ParsingResult .Ok (header, errors) if errors.isEmpty => header
196+ case ParsingResult .Ok (_, errors) => throw ParsingException (errors.head)
197+ case ParsingResult .Error (info) => throw ParsingException (info)
198+ }
201199 }
202200
203201 private [http2] def checkRequiredPseudoHeader (name : String , value : AnyRef ): Unit =
0 commit comments