Merge pull request #19673 from newca12/newca12-#19610-fix-multipart-form-data-unmarshaller
=htp fix multipart/form-data unmarshaller when no Content-Type field
This commit is contained in:
commit
442d10d123
2 changed files with 12 additions and 1 deletions
|
|
@ -236,10 +236,20 @@ class MultipartUnmarshallersSpec extends FreeSpec with Matchers with BeforeAndAf
|
|||
}
|
||||
|
||||
"multipartFormDataUnmarshaller should correctly unmarshal 'multipart/form-data' content" - {
|
||||
"with one element and no explicit content-type" in {
|
||||
Unmarshal(HttpEntity(`multipart/form-data` withBoundary "XYZABC" withCharset `UTF-8`,
|
||||
"""--XYZABC
|
||||
|content-disposition: form-data; name=email
|
||||
|
|
||||
|test@there.com
|
||||
|--XYZABC--""".stripMarginWithNewline("\r\n"))).to[Multipart.FormData] should haveParts(
|
||||
Multipart.FormData.BodyPart.Strict("email", HttpEntity(ContentTypes.`text/plain(UTF-8)`, "test@there.com")))
|
||||
}
|
||||
"with one element" in {
|
||||
Unmarshal(HttpEntity(`multipart/form-data` withBoundary "XYZABC" withCharset `UTF-8`,
|
||||
"""--XYZABC
|
||||
|content-disposition: form-data; name=email
|
||||
|Content-Type: application/octet-stream
|
||||
|
|
||||
|test@there.com
|
||||
|--XYZABC--""".stripMarginWithNewline("\r\n"))).to[Multipart.FormData] should haveParts(
|
||||
|
|
@ -255,6 +265,7 @@ class MultipartUnmarshallersSpec extends FreeSpec with Matchers with BeforeAndAf
|
|||
ByteString {
|
||||
"""--XYZABC
|
||||
|Content-Disposition: form-data; name="email"
|
||||
|Content-Type: application/octet-stream
|
||||
|
|
||||
|test@there.com
|
||||
|--XYZABC
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ trait MultipartUnmarshallers {
|
|||
implicit def multipartFormDataUnmarshaller(implicit log: LoggingAdapter = NoLogging, parserSettings: ParserSettings = null): FromEntityUnmarshaller[Multipart.FormData] =
|
||||
multipartUnmarshaller[Multipart.FormData, Multipart.FormData.BodyPart, Multipart.FormData.BodyPart.Strict](
|
||||
mediaRange = `multipart/form-data`,
|
||||
defaultContentType = ContentTypes.`application/octet-stream`,
|
||||
defaultContentType = ContentTypes.`text/plain(UTF-8)`,
|
||||
createBodyPart = (entity, headers) ⇒ Multipart.General.BodyPart(entity, headers).toFormDataBodyPart.get,
|
||||
createStreamed = (_, parts) ⇒ Multipart.FormData(parts),
|
||||
createStrictBodyPart = (entity, headers) ⇒ Multipart.General.BodyPart.Strict(entity, headers).toFormDataBodyPart.get,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue