This module contains many helper functions, as well the code for Source
,
which is a pretty important structure
- type Source = IO SourceResult
- data SourceResult
- bsSource :: ByteString -> IO Source
- hSource :: (Int64, Int64) -> Handle -> IO Source
- nullSource :: Source
- sourceToLBS :: Source -> IO ByteString
- sourceToBS :: Int -> Source -> IO (Maybe ByteString)
- connSource :: Int64 -> ByteString -> Connection -> IO Source
- connChunkedSource :: Connection -> IO Source
- connEOFSource :: Connection -> IO Source
- sourceDrain :: Source -> IO ()
- streamSource :: Int -> Connection -> Source -> IO Bool
- streamSourceChunked :: Int -> Connection -> Source -> IO Bool
- readIG :: Connection -> Int -> Int -> Get a a -> IO (Maybe a)
- sourceIG :: Source -> Int -> Get a a -> IO (Maybe a)
- maybeRead :: Read a => ByteString -> Maybe a
- sslToBaseConnection :: SSL -> BaseConnection
Sources, and related functions
type Source = IO SourceResultSource
A source is a stream of data, like a lazy data structure, but without
some of the dangers that such entail. A source returns a SourceResult
each time you evaluate it.
data SourceResult Source
SourceError | error - please don't read this source again |
SourceEOF | end of data |
SourceData ByteString | some data |
bsSource :: ByteString -> IO SourceSource
Construct a source from a ByteString
Construct a source from a Handle
A source with no data (e.g. devnull
)
sourceToLBS :: Source -> IO ByteStringSource
Convert a source to a lazy ByteString
sourceToBS :: Int -> Source -> IO (Maybe ByteString)Source
Take, at most, the first n bytes from a Source and return a strict ByteString. Returns Nothing on error. (A short read is not an error)
:: Int64 | the number of bytes to read |
-> ByteString | a string which is prepended to the output |
-> Connection | the connection to read from |
-> IO Source |
A source which reads from a Connection
connChunkedSource :: Connection -> IO SourceSource
A source which reads an HTTP chunked reply from a Connection
connEOFSource :: Connection -> IO SourceSource
A source which reads from the given Connection
until the connection
signals end-of-file.
streamSource :: Int -> Connection -> Source -> IO BoolSource
Stream a source to a connection while not enqueuing more than lowWater bytes in the outbound queue (not inc the kernel buffer)
streamSourceChunked :: Int -> Connection -> Source -> IO BoolSource
Stream a source to a connection, with chunked encoding, while not enqueuing more than lowWater bytes in the outbound queue (not inc the kernel buffer)
Misc functions
:: Connection | the connection to read from |
-> Int | the block size to use |
-> Int | maximum number of bytes to parse |
-> Get a a | the parser |
-> IO (Maybe a) |
Run an incremental parser from the network
:: Source | the source to read from |
-> Int | the maximum number of bytes to parse |
-> Get a a | the parser |
-> IO (Maybe a) |
Run an incremental parser from a Source
maybeRead :: Read a => ByteString -> Maybe aSource
sslToBaseConnection :: SSL -> BaseConnectionSource
Convert an SSL connection to a BaseConnection for Network.Connection