Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[#302] Makes it possible to set Headers for an Async result

  • Loading branch information...
commit 72acd089349f300e968f453a03f4c70bf608fe36 1 parent 843f033
jto authored
11 framework/src/play/src/main/scala/play/core/j/JavaResults.scala
@@ -25,7 +25,16 @@ object JavaResults extends Results with DefaultWriteables with DefaultContentTyp
25 25 def contentTypeOfBytes(mimeType: String): ContentTypeOf[Array[Byte]] = ContentTypeOf(Option(mimeType).orElse(Some("application/octet-stream")))
26 26 def emptyHeaders = Map.empty[String, String]
27 27 def empty = Results.EmptyContent()
28   - def async(p: play.api.libs.concurrent.Promise[Result]) = AsyncResult(p)
  28 + def async(p: play.api.libs.concurrent.Promise[Result]) = {
  29 + import scala.collection.JavaConverters.mapAsScalaMapConverter
  30 + val rsp = play.mvc.Http.Context.current().response()
  31 + AsyncResult(p.map {
  32 + case r: PlainResult =>
  33 + r.withHeaders((rsp.getHeaders().asScala -- r.header.headers.keys).toList:_*)
  34 + case r =>
  35 + r
  36 + })
  37 + }
29 38 def chunked[A](onDisconnected: () => Unit) = play.api.libs.iteratee.Enumerator.imperative[A](onComplete = { onDisconnected() })
30 39 def chunked(stream: java.io.InputStream, chunkSize: Int) = Enumerator.fromStream(stream, chunkSize)
31 40 def chunked(file: java.io.File, chunkSize: Int) = Enumerator.fromFile(file, chunkSize)

0 comments on commit 72acd08

Please sign in to comment.
Something went wrong with that request. Please try again.