Skip to content

Commit 4696e75

Browse files
committed
fix: improve handling of asterisk in HTTP/2 ':path' pseudo-header
1 parent 8985ffe commit 4696e75

2 files changed

Lines changed: 7 additions & 4 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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,15 @@ class RequestParsingSpec extends PekkoSpecWithMaterializer with Inside with Insp
449449
// ... A request in asterisk form includes the
450450
// value '*' for the ":path" pseudo-header field.
451451

452-
"handle a ':path' with an asterisk" in pendingUntilFixed {
452+
"handle a ':path' with an asterisk" in {
453453
val request: HttpRequest = parseExpectOk(
454454
keyValuePairs = Vector(
455455
":method" -> "OPTIONS",
456456
":scheme" -> "http",
457-
":path" -> "*"))
458-
request.uri.toString should ===("*") // FIXME: Compare in a better way
457+
":path" -> "*"
458+
))
459+
request.uri.path.toString should ===("")
460+
request.uri.rawQueryString should ===(None)
459461
}
460462

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

0 commit comments

Comments
 (0)