rocketraman
07/10/2018, 4:19 PMrocketraman
07/10/2018, 4:24 PMfun main(args: Array<String>) = runBlocking {
val client = HttpClient(CIO.config { })
suspend fun responseHandler(counter: Int, call: HttpClientCall) {
println("-=-=-= response handling $counter")
val readChannel = call.response.content
println("-=-=-= readChannel $counter=$readChannel")
}
client.call("<http://localhost:8096/internal/LLQD6-89TNKjjgRaVtMc2Q>").use {
responseHandler(1, it)
}
println("Second attempt!")
client.call("<http://localhost:8096/internal/LLQD6-89TNKjjgRaVtMc2Q>").use {
responseHandler(2, it)
}
}
Output:
-=-=-= response handling 1
-=-=-= readChannel 1=kotlinx.coroutines.experimental.io.ByteBufferChannel@1f7030a6
Second attempt!
The second call never unsuspends, and there is no thread in the system waiting for the response.rocketraman
07/10/2018, 4:27 PMval client = HttpClient(Apache)
orangy
Deactivated User
07/10/2018, 5:43 PMe5l
07/10/2018, 5:44 PMrocketraman
07/10/2018, 5:45 PMclose
would release any resources.rocketraman
07/10/2018, 5:45 PMDeactivated User
07/10/2018, 5:45 PMe5l
07/10/2018, 5:46 PMrocketraman
07/10/2018, 5:50 PMclient.call("<http://localhost:8096/internal/LLQD6-89TNKjjgRaVtMc2Q>") {
this.header("Connection", "Close")
}.use {
responseHandler(1, it)
}
If so, still didn't work.rocketraman
07/10/2018, 5:51 PMClose
wrong. Yes, that worked.rocketraman
07/10/2018, 5:51 PMe5l
07/10/2018, 5:52 PMe5l
07/10/2018, 5:52 PMrocketraman
07/10/2018, 5:53 PMe5l
07/10/2018, 5:54 PMrocketraman
07/10/2018, 5:54 PMe5l
07/10/2018, 5:56 PMe5l
07/10/2018, 5:56 PMrocketraman
07/10/2018, 6:02 PMclose
not automatically discard the first response in the pipeline though?e5l
07/10/2018, 6:07 PMrocketraman
07/10/2018, 6:08 PMe5l
07/10/2018, 6:08 PMrocketraman
07/10/2018, 6:09 PMe5l
07/10/2018, 6:12 PMDeactivated User
07/10/2018, 6:13 PMrocketraman
07/10/2018, 6:15 PMrocketraman
07/10/2018, 6:16 PMval readChannel= call.receive<ByteReadChannel>()
has the same behaviorDeactivated User
07/10/2018, 6:22 PMDeactivated User
07/10/2018, 6:23 PMDeactivated User
07/10/2018, 6:23 PMrocketraman
07/10/2018, 6:24 PMrocketraman
07/10/2018, 6:24 PMByteReadChannel
. My point is that should either by a) documented, or b) the close
on the call
should automatically discard any unread bytes.Deactivated User
07/10/2018, 6:25 PMDeactivated User
07/10/2018, 6:25 PMDeactivated User
07/10/2018, 6:25 PMDeactivated User
07/10/2018, 6:38 PM