I've tried to use client as it shown in README and find out that bodyAsString is waiting connection closing (end of stream). My server doesn't close connection by itself, it waiting closing by client. I've write some code to show what I mean.
val request = HttpRequest.get[Task](Uri.https("fomkin.org", "/hello-world.txt"))
val startTime = System.currentTimeMillis
client.request(request).flatMap { resp =>
val task = resp.body.runFold(ByteBuffer.allocate(resp.bodySize.get.toInt)) {
case (buffer, byte) =>
val t = System.currentTimeMillis - startTime
println(s"${t}ms: ${byte.toChar}")
buffer.put(byte)
buffer
}
Stream.eval(task)
}.runLog.map { xs =>
val t = System.currentTimeMillis - startTime
println(s"${t}ms: --")
println(xs.map(x => new String(x.array())))
}
It prints something like
1033ms: H
1033ms: e
1033ms: l
1033ms: l
1033ms: o
1033ms:
1033ms: W
1033ms: o
1033ms: r
1033ms: l
1033ms: d
6624ms: --
Hello World
I think body should be finalized when count of emited bytes equals to content-length. Stream should be infinite only when content-length is not defined.
Hi guys!
I've tried to use client as it shown in README and find out that
bodyAsString
is waiting connection closing (end of stream). My server doesn't close connection by itself, it waiting closing by client. I've write some code to show what I mean.It prints something like
Last two line prints only when I reboot nginx.