Skip to content

Commit 53c8772

Browse files
committed
fix: improve handling of asterisk in HTTP/2 ':path' pseudo-header
1 parent a0f6379 commit 53c8772

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/UriParser.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ private[http] final class UriParser(
351351
// https://tools.ietf.org/html/rfc7540#section-8.1.2.3
352352
def `http2-path-pseudo-header` = rule(
353353
`absolute-path` ~ optional('?' ~ rawQueryString) // origin-form
354-
) // TODO: asterisk-form
354+
| '*' ~ run(setPath(Path.Empty)) ~ run { _rawQueryString = None } // asterisk-form (for OPTIONS requests)
355+
)
355356

356357
/**
357358
* @return path and percent-encoded query string. When in in 'relaxed' mode, characters not permitted by https://tools.ietf.org/html/rfc3986#section-3.4

http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/RequestParsingSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,15 @@ class RequestParsingSpec extends PekkoSpecWithMaterializer with Inside with Insp
456456
// ... A request in asterisk form includes the
457457
// value '*' for the ":path" pseudo-header field.
458458

459-
"handle a ':path' with an asterisk" in pendingUntilFixed {
459+
"handle a ':path' with an asterisk" in {
460460
val request: HttpRequest = parseExpectOk(
461461
keyValuePairs = Vector(
462462
":method" -> "OPTIONS",
463463
":scheme" -> "http",
464464
":path" -> "*"
465465
))
466-
request.uri.toString should ===("*") // FIXME: Compare in a better way
466+
request.uri.path.toString should ===("")
467+
request.uri.rawQueryString should ===(None)
467468
}
468469

469470
// [The ":path"] pseudo-header field MUST NOT be empty for "http" or "https"

0 commit comments

Comments
 (0)