Stability | experimental |
---|---|
Maintainer | Ertugrul Soeylemez <[email protected]> |
Network.NetLines
Description
Enumerator tools for working with text-based network protocols.
- netLine :: forall m r. Monad m => Int -> MaybeT r (Iteratee ByteString m) ByteString
- netLines :: forall b m. Monad m => Int -> Enumeratee ByteString ByteString m b
- netLineEmpty :: Monad m => Int -> MaybeT r (Iteratee ByteString m) ByteString
- netLinesEmpty :: forall b m. Monad m => Int -> Enumeratee ByteString ByteString m b
- enumHandleTimeout :: forall b m. MonadIO m => Int -> Int -> Handle -> Enumerator ByteString m b
Conversion to lines
netLine :: forall m r. Monad m => Int -> MaybeT r (Iteratee ByteString m) ByteStringSource
Savely read a line with the given maximum length. If a longer line
is enumerated, the excess data is dropped in constant space. Returns
Nothing
on EOF.
Please note that this function is very error-tolerant in the way it handles line endings. Both CR and LF are proper line terminators. This function ignores empty lines.
netLines :: forall b m. Monad m => Int -> Enumeratee ByteString ByteString m bSource
Convert a stream of bytes to a stream of lines with the given maximum length. Longer lines are silently truncated in constant space.
Conversion to sparse lines
netLineEmpty :: Monad m => Int -> MaybeT r (Iteratee ByteString m) ByteStringSource
Variant of netLine
, which supports empty lines, useful for
protocols like HTTP, in which empty lines have a special meaning.
This function splits the input stream by LF characters while ignoring
CR characters.
netLinesEmpty :: forall b m. Monad m => Int -> Enumeratee ByteString ByteString m bSource
This is the same like netLines
, but is based on netLinesEmpty
to support empty lines.
Enumerators
enumHandleTimeout :: forall b m. MonadIO m => Int -> Int -> Handle -> Enumerator ByteString m bSource
Enumerate from a handle with the given buffer size (first argument)
and timeout in milliseconds (second argument). If the timeout is
exceeded an exception is thrown via throwError
.