playframework/Play20 — pull request #959 by jroper (2013-04-15 05:58:50+00:00)
Title: Chunked result doesn't close connection

In play2.1.1, Ok.stream does not close connection.

``` scala
object Test extends Controller {

def test = Action {
import play.api.libs.iteratee.Enumerator
Ok.stream(Enumerator("foo", "bar"))
}
}
```

Here is what i observe:
```
$ curl -v http://localhost:9000/test
* About to connect() to localhost port 9000 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 9000 (#0)
> GET /test HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:9000
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
<
```

And curl stops here.

Here is a workaround found by @vmunier :
``` scala
object Test extends Controller {

def test = Action {
import play.api.libs.iteratee.Enumerator
Ok.stream(Enumerator("foo", "bar").andThen(Enumerator.eof[String]))
}
}
```

which results in:
```
$ curl -v http://localhost:9000/test
* About to connect() to localhost port 9000 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 9000 (#0)
> GET /test HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:9000
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0
foobar
```

Which is what i expect to see