Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions OpenSSL/Session.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,17 @@ sslIOInner loc f ptr nbytes ssl
-- | Try to read the given number of bytes from an SSL connection. On EOF an
-- empty ByteString is returned. If the connection dies without a graceful
-- SSL shutdown, an exception is raised.
--
-- NOTE: The returned bytestring could be shorter than the size requested, see:
-- https://www.openssl.org/docs/man3.0/man3/SSL_read.html
read :: SSL -> Int -> IO B.ByteString
read ssl nBytes = sslBlock (`tryRead` nBytes) ssl

-- | Try to read the given number of bytes from an SSL connection
-- without blocking.
--
-- NOTE: The returned bytestring could be shorter than the size requested, see:
-- https://www.openssl.org/docs/man3.0/man3/SSL_read.html
tryRead :: SSL -> Int -> IO (SSLResult B.ByteString)
tryRead ssl nBytes
= do (bs, result) <- B.createAndTrim' nBytes $ \bufPtr ->
Expand Down