Skip to content

Commit

Permalink
reorganize sendData slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenthz committed Jan 25, 2012
1 parent 80998d0 commit 4f45093
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Network/TLS/Core.hs
Expand Up @@ -480,16 +480,13 @@ handshake ctx = do
-- | sendData sends a bunch of data.
-- It will automatically chunk data to acceptable packet size
sendData :: MonadIO m => TLSCtx c -> L.ByteString -> m ()
sendData ctx dataToSend = do
checkValid ctx
mapM_ sendDataChunk (L.toChunks dataToSend)
where sendDataChunk d = if B.length d > 16384
then do
let (sending, remain) = B.splitAt 16384 d
sendPacket ctx $ AppData sending
sendDataChunk remain
else
sendPacket ctx $ AppData d
sendData ctx dataToSend = checkValid ctx >> mapM_ sendDataChunk (L.toChunks dataToSend)
where sendDataChunk d
| B.length d > 16384 = do
let (sending, remain) = B.splitAt 16384 d
sendPacket ctx $ AppData sending
sendDataChunk remain
| otherwise = sendPacket ctx $ AppData d

-- | recvData get data out of Data packet, and automatically renegociate if
-- a Handshake ClientHello is received
Expand Down

0 comments on commit 4f45093

Please sign in to comment.