Merge pull request #16206 from spray/w/16175-regard-raw-request-uri-header-setting
=htc #16175 regard `raw-request-uri-header` setting
This commit is contained in:
commit
77fee04976
2 changed files with 23 additions and 2 deletions
|
|
@ -110,8 +110,12 @@ private[http] class HttpRequestParser(_settings: ParserSettings,
|
||||||
hostHeaderPresent: Boolean, closeAfterResponseCompletion: Boolean): StateResult =
|
hostHeaderPresent: Boolean, closeAfterResponseCompletion: Boolean): StateResult =
|
||||||
if (hostHeaderPresent || protocol == HttpProtocols.`HTTP/1.0`) {
|
if (hostHeaderPresent || protocol == HttpProtocols.`HTTP/1.0`) {
|
||||||
def emitRequestStart(createEntity: Source[ParserOutput.RequestOutput] ⇒ RequestEntity,
|
def emitRequestStart(createEntity: Source[ParserOutput.RequestOutput] ⇒ RequestEntity,
|
||||||
headers: List[HttpHeader] = headers) =
|
headers: List[HttpHeader] = headers) = {
|
||||||
emit(ParserOutput.RequestStart(method, uri, protocol, headers, createEntity, closeAfterResponseCompletion))
|
val allHeaders =
|
||||||
|
if (rawRequestUriHeader) `Raw-Request-URI`(new String(uriBytes, HttpCharsets.`US-ASCII`.nioCharset)) :: headers
|
||||||
|
else headers
|
||||||
|
emit(ParserOutput.RequestStart(method, uri, protocol, allHeaders, createEntity, closeAfterResponseCompletion))
|
||||||
|
}
|
||||||
|
|
||||||
teh match {
|
teh match {
|
||||||
case None ⇒
|
case None ⇒
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,23 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll {
|
||||||
closeAfterResponseCompletion shouldEqual Seq(false)
|
closeAfterResponseCompletion shouldEqual Seq(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"support `rawRequestUriHeader` setting" in new Test {
|
||||||
|
override protected def newParser: HttpRequestParser = new HttpRequestParser(parserSettings, rawRequestUriHeader = true)()
|
||||||
|
|
||||||
|
"""GET /f%6f%6fbar?q=b%61z HTTP/1.1
|
||||||
|
|Host: ping
|
||||||
|
|Content-Type: application/pdf
|
||||||
|
|
|
||||||
|
|""" should parseTo(
|
||||||
|
HttpRequest(
|
||||||
|
GET,
|
||||||
|
"/foobar?q=baz",
|
||||||
|
List(
|
||||||
|
`Raw-Request-URI`("/f%6f%6fbar?q=b%61z"),
|
||||||
|
Host("ping")),
|
||||||
|
HttpEntity.empty(`application/pdf`)))
|
||||||
|
}
|
||||||
|
|
||||||
"reject a message chunk with" - {
|
"reject a message chunk with" - {
|
||||||
val start =
|
val start =
|
||||||
"""PATCH /data HTTP/1.1
|
"""PATCH /data HTTP/1.1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue