diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/BodyPartParser.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/BodyPartParser.scala index bf8578e53e..7086f937a9 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/BodyPartParser.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/BodyPartParser.scala @@ -98,7 +98,7 @@ private[http] final class BodyPartParser(defaultContentType: ContentType, else parsePreamble(input, 0) } else parsePreamble(input, 0) } catch { - case NotEnoughDataException ⇒ continue((input, _) ⇒ tryParseInitialBoundary(input)) + case NotEnoughDataException ⇒ continue(input, 0)((newInput, _) ⇒ tryParseInitialBoundary(newInput)) } def parsePreamble(input: ByteString, offset: Int): StateResult = diff --git a/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/MultipartUnmarshallersSpec.scala b/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/MultipartUnmarshallersSpec.scala index 306571d2f7..505821ecfb 100644 --- a/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/MultipartUnmarshallersSpec.scala +++ b/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/MultipartUnmarshallersSpec.scala @@ -49,7 +49,7 @@ class MultipartUnmarshallersSpec extends FreeSpec with Matchers with BeforeAndAf |--XYZABC--""".stripMarginWithNewline("\r\n"))).to[Multipart.General] should haveParts( Multipart.General.BodyPart.Strict(HttpEntity.empty(MediaTypes.`text/xml`), List(Age(12)))) } - "an implicitly typed part (without headers)" in { + "an implicitly typed part (without headers) (Strict)" in { Unmarshal(HttpEntity(`multipart/mixed` withBoundary "XYZABC", """--XYZABC | @@ -57,6 +57,16 @@ class MultipartUnmarshallersSpec extends FreeSpec with Matchers with BeforeAndAf |--XYZABC--""".stripMarginWithNewline("\r\n"))).to[Multipart.General] should haveParts( Multipart.General.BodyPart.Strict(HttpEntity(ContentTypes.`text/plain(UTF-8)`, "Perfectly fine part content."))) } + "an implicitly typed part (without headers) (Default)" in { + val content = """--XYZABC + | + |Perfectly fine part content. + |--XYZABC--""".stripMarginWithNewline("\r\n") + val byteStrings = content.map(c ⇒ ByteString(c.toString)) // one-char ByteStrings + Unmarshal(HttpEntity.Default(`multipart/mixed` withBoundary "XYZABC", content.length, Source(byteStrings))) + .to[Multipart.General] should haveParts( + Multipart.General.BodyPart.Strict(HttpEntity(ContentTypes.`text/plain(UTF-8)`, "Perfectly fine part content."))) + } "one non-empty form-data part" in { Unmarshal(HttpEntity(`multipart/form-data` withBoundary "-", """---