corneil
07/10/2022, 5:52 PMjanvladimirmostert
07/10/2022, 6:31 PMwithContext(<http://Dispatchers.IO|Dispatchers.IO>) {
channel.write(ByteBuffer.wrap(data)).get()
channel.close()
}
net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
There must be a better way to do close()
that won't cut off the stream while the browser is readingcorneil
07/10/2022, 6:36 PMjanvladimirmostert
07/10/2022, 6:39 PMnet::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
When you're done writing and the completion handler is called, it doesn't actually mean that the browser received your written data, just that the kernel received your data and calling close() too soon wipes the buffer before the browser can read itcorneil
07/10/2022, 6:46 PMjanvladimirmostert
07/10/2022, 6:52 PMcorneil
07/10/2022, 6:59 PMjanvladimirmostert
07/10/2022, 7:02 PMcorneil
07/10/2022, 7:48 PMjanvladimirmostert
07/10/2022, 7:51 PMheaders.add("Content-Length: ${body.length}")
corneil
07/10/2022, 7:57 PMjanvladimirmostert
07/10/2022, 8:09 PMcorneil
07/10/2022, 8:15 PMjanvladimirmostert
07/10/2022, 8:18 PMcorneil
07/10/2022, 8:18 PMjanvladimirmostert
07/10/2022, 8:19 PMcorneil
07/10/2022, 8:21 PMclose
then close the socket otherwise leave the socket open.janvladimirmostert
07/10/2022, 8:30 PMcorneil
07/10/2022, 9:26 PMjanvladimirmostert
07/10/2022, 9:44 PMsupervisorScope {
launch(<http://Dispatchers.IO|Dispatchers.IO>) {
log.warn("New Connection!!")
// create re-usable buffer
val buffer = ByteBuffer.allocate(bufferSize.B)
while (channel.isOpen) {
val parser = readRequest(channel = channel, buffer = buffer.rewind())
writeResponse(channel = channel, parser = parser)
}
}
}
let's see if this fixes the AWS Load Balancer problem which seems to ignore my response headers