File tree 2 files changed +16
-1
lines changed
ktor-network/ktor-network-tls/jvm
test/io/ktor/network/tls/tests 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ private class TLSSocket(
48
48
appDataOutputLoop(this .channel)
49
49
}
50
50
51
- @OptIn(ExperimentalCoroutinesApi ::class )
52
51
private suspend fun appDataInputLoop (pipe : ByteWriteChannel ) {
53
52
try {
54
53
input.consumeEach { record ->
@@ -80,6 +79,8 @@ private class TLSSocket(
80
79
buffer.flip()
81
80
output.send(TLSRecord (TLSRecordType .ApplicationData , packet = buildPacket { writeFully(buffer) }))
82
81
}
82
+ } catch (_: ClosedSendChannelException ) {
83
+ // The socket was already closed, we should ignore that error.
83
84
} finally {
84
85
output.close()
85
86
}
Original file line number Diff line number Diff line change @@ -57,6 +57,20 @@ class ConnectionTest {
57
57
Unit
58
58
}
59
59
60
+ @Test
61
+ fun tlsWithCloseTest (): Unit = runBlocking {
62
+ val selectorManager = ActorSelectorManager (Dispatchers .IO )
63
+ val socket = aSocket(selectorManager)
64
+ .tcp()
65
+ .connect(" www.google.com" , port = 443 )
66
+ .tls(Dispatchers .Default )
67
+
68
+ val channel = socket.openWriteChannel(autoFlush = true )
69
+ socket.close()
70
+ assertEquals(42 , channel.writeAvailable(ByteArray (42 )))
71
+ assertTrue(channel.isClosedForWrite)
72
+ }
73
+
60
74
@Test
61
75
@Ignore
62
76
fun clientCertificatesAuthTest () {
You can’t perform that action at this time.
0 commit comments