1

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
4

1 回答 1

1

这有效(内容类型仍然是 application/pdf)(注意:使用此代码来测试处理二进制流的操作):

route(FakeRequest(POST,
                  controllers.routes.FilesController.filesEndpointPost().url,
                  FakeHeaders(Seq(CONTENT_TYPE->Seq("application/pdf"))),
                  "brokenpdf"))
      (new Writeable({s:String => s.getBytes}, None)
     ).get
于 2013-01-24T07:40:25.920 回答