Reputation: 37
What should I do if I want to disconnect while still receiving responses from RestClient? (java, kotlin)
val result = restClient().get()
.uri("")
.exchange { : HttpRequest, response: RestClient.RequestHeadersSpec.ConvertibleClientHttpResponse ->
try {
response.body.use { inputStream ->
inputStream.use {
.. do somethings
response.close() // want force close
}
}
} catch (e:IOException) {
//
}
...
}
I found that response.close() blocks until the stream is fully received. Is there a good way to immediately disconnect?
Upvotes: 0
Views: 34