davidasync
03/14/2019, 9:19 AMe5l
03/14/2019, 9:30 AMdavidasync
03/14/2019, 9:31 AMe5l
03/14/2019, 9:35 AMdavidasync
03/14/2019, 9:41 AMclientResponse.close()
before responseCallback.onComplete(response)
?davidasync
03/14/2019, 10:39 AMI/O reactor status: STOPPED
at org.apache.http.util.Asserts.check(Asserts.java:46)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.ensureRunning(CloseableHttpAsyncClientBase.java:90)
at
e5l
03/14/2019, 11:19 AMdavidasync
03/14/2019, 11:25 AMval clientResponse = httpClient!!.use { httpClient ->
httpClient.call {
method = requestMethod
url(requestUrl)
body = TextContent(requestBody, requestContentType)
request.headers.forEach {
if (!unsafeHeaderSet.contains(it.name)) {
header(it.name, it.value)
}
}
}.response
}
response.statusCode = clientResponse.status.value
response.bodyEncoding = "UTF-8"
clientResponse.headers.forEach { name, value ->
val headerValue = value.joinToString(",")
response.addHeader(name, headerValue)
}
clientResponse.readBytes()
val responseBodyString = String(clientResponse.readBytes())
response.body = IndirectNIOBuffer(ByteBuffer.wrap(responseBodyString.toByteArray(charset("UTF-8"))), true)
responseCallback.onComplete(response)
Take a look at this code is it okay?e5l
03/14/2019, 11:27 AMe5l
03/14/2019, 11:29 AMhttpClient.use
and close the client on the application shutdowndavidasync
03/14/2019, 11:32 AMdavidasync
03/14/2019, 11:33 AMgotoOla
03/14/2019, 1:09 PMgotoOla
03/14/2019, 1:10 PMe5l
03/14/2019, 1:16 PMuse
?e5l
03/14/2019, 1:16 PMcall
or HttpResponse
explicit.gotoOla
03/14/2019, 3:38 PMdavidasync
03/14/2019, 4:16 PMHeaders and descriptors are released only after the close.
e5l
03/15/2019, 10:13 AMresponse: HttpResponse
you take the network stream with bytes inside(to consume it on demand).