-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Validate custom HTTP method names #4460
- Loading branch information
Showing
3 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
akka-http-core/src/test/scala/akka/http/scaladsl/model/HttpMethodSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2009-2024 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.http.scaladsl.model | ||
|
||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
|
||
class HttpMethodSpec extends AnyWordSpec with Matchers { | ||
"HttpMethod.custom()" should { | ||
"accept a valid name" in { | ||
HttpMethod.custom("Yes.Thi$_is_1~'VAL|D`_me+h*d-^ame!#%&") | ||
} | ||
"validate that an invalid character is not present" in { | ||
an[Exception] should be thrownBy HttpMethod.custom("INJECT /path HTTP/1.1\r\n") | ||
an[Exception] should be thrownBy HttpMethod.custom("INJECT\r\n") | ||
an[Exception] should be thrownBy HttpMethod.custom("INJECT ") | ||
} | ||
} | ||
} |