Skip to content

Instantly share code, notes, and snippets.

@jkyamog
Created February 11, 2014 22:50
Show Gist options
  • Save jkyamog/8945955 to your computer and use it in GitHub Desktop.
Save jkyamog/8945955 to your computer and use it in GitHub Desktop.
case class TestRequestHeader(headers: Headers, method: String = "GET", uri: String = "/", path: String = "", remoteAddress: String = "127.0.0.1", version: String = "HTTP/1.1", id: Long = 666, tags: Map[String, String] = Map.empty[String, String], queryString: Map[String, Seq[String]] = Map(), secure: Boolean = false) extends RequestHeader
val rh = TestRequestHeader(headers = new Headers {
val data = Seq(play.api.http.HeaderNames.CONTENT_TYPE -> Seq("""multipart/form-data; boundary=----68766594719920667221395339924"""), play.api.http.HeaderNames.CONTENT_LENGTH -> Seq("380"))
})
val multipartFormData = BodyParsers.parse.multipartFormData
val testStr = """Content-Type: multipart/form-data; boundary=---------------------------68766594719920667221395339924
Content-Length: 380
-----------------------------68766594719920667221395339924
Content-Disposition: form-data; name="picture"; filename="README"
Content-Type: application/octet-stream
This is your new Play application
=====================================
This file will be packaged with your application, when using `play dist`.
-----------------------------68766594719920667221395339924--
"""
val enumerator = Enumerator(testStr.getBytes)
val iteratee = multipartFormData(rh)
val fResult = enumerator run iteratee
val result = Await.result(fResult, Duration("5 seconds"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment