Reputation: 615
I want to set content-type of Fake Request (Play 2.1-RC2). Following code doesn't work (an action receives application/octet-stream instead of application/pdf)
route(FakeRequest(POST,
controllers.routes.FilesController.filesEndpointPost().url,
FakeHeaders(Seq(CONTENT_TYPE->Seq("application/pdf"))),
AnyContentAsRaw(RawBuffer(1000,"brokenpdf".getBytes))
)
).get
Upvotes: 1
Views: 1368
Reputation: 615
This works(content type remains application/pdf)(note: use this code to test actions processing binary streams):
route(FakeRequest(POST,
controllers.routes.FilesController.filesEndpointPost().url,
FakeHeaders(Seq(CONTENT_TYPE->Seq("application/pdf"))),
"brokenpdf"))
(new Writeable({s:String => s.getBytes}, None)
).get
Upvotes: 1