Pergunta

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
Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top