=htc Bugfix #21243 absolute request target parsing broken (#21244)

This commit is contained in:
Johan Andrén 2016-08-23 01:58:10 +02:00 committed by Konrad Malawski
parent caa98c0110
commit 09c656c21d
4 changed files with 15 additions and 4 deletions

View file

@ -23,7 +23,7 @@ import akka.util.ByteString
final class ByteStringParserInput(bytes: ByteString) extends DefaultParserInput {
override def charAt(ix: Int): Char = (bytes(ix) & 0xFF).toChar
override def length: Int = bytes.size
override def sliceString(start: Int, end: Int): String = bytes.slice(start, end - start).decodeString(StandardCharsets.ISO_8859_1)
override def sliceString(start: Int, end: Int): String = bytes.slice(start, end).decodeString(StandardCharsets.ISO_8859_1)
override def sliceCharArray(start: Int, end: Int): Array[Char] =
StandardCharsets.ISO_8859_1.decode(bytes.slice(start, end).asByteBuffer).array()
}

View file

@ -42,7 +42,7 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
akka.event-handlers = ["akka.testkit.TestEventListener"]
akka.loglevel = WARNING
akka.http.parsing.max-header-value-length = 32
akka.http.parsing.max-uri-length = 20
akka.http.parsing.max-uri-length = 40
akka.http.parsing.max-content-length = 4000000000""")
implicit val system = ActorSystem(getClass.getSimpleName, testConf)
import system.dispatcher
@ -79,6 +79,14 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
closeAfterResponseCompletion shouldEqual Seq(false)
}
"with absolute uri in request-target" in new Test {
"""GET http://127.0.0.1:8080/hello HTTP/1.1
|Host: 127.0.0.1:8080
|
|""" should parseTo(HttpRequest(uri = "http://127.0.0.1:8080/hello", headers = List(Host("127.0.0.1", 8080))))
closeAfterResponseCompletion shouldEqual Seq(false)
}
"with 3 headers and a body" in new Test {
"""POST /resource/yes HTTP/1.0
|User-Agent: curl/7.19.7 xyz
@ -408,9 +416,9 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
}
"a too-long URI" in new Test {
"GET /23456789012345678901 HTTP/1.1" should parseToError(
"GET /2345678901234567890123456789012345678901 HTTP/1.1" should parseToError(
RequestUriTooLong,
ErrorInfo("URI length exceeds the configured limit of 20 characters"))
ErrorInfo("URI length exceeds the configured limit of 40 characters"))
}
"HTTP version 1.2" in new Test {

View file

@ -293,6 +293,8 @@ class HttpHeaderSpec extends FreeSpec with Matchers {
"Host: [2001:db8::1]" =!= Host("[2001:db8::1]")
"Host: [::FFFF:129.144.52.38]" =!= Host("[::FFFF:129.144.52.38]")
"Host: spray.io:80000" =!= ErrorInfo("Illegal HTTP header 'Host': requirement failed", "Illegal port: 80000")
"Host: 127.0.0.1:9000" =!= Host("127.0.0.1", 9000)
"Host: 127.0.0.1" =!= Host("127.0.0.1")
}
"If-Match" in {

View file

@ -18,6 +18,7 @@ class ByteStringParserInputSpec extends WordSpec with Matchers {
"slice the bytes correctly into a string" in {
parser.sliceString(0, 3) should ===("abc")
parser.sliceString(3, 5) should ===("de")
}
"slice the bytes correctly into a char array" in {