network-minihttp-0.2: A ByteString based library for writing HTTP(S) servers and clients.

Network.MiniHTTP.HTTPConnection

Contents

Description

This module contains many helper functions, as well the code for Source, which is a pretty important structure

Synopsis

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

Constructors

SourceError

error - please don't read this source again

SourceEOF

end of data

SourceData ByteString

some data

Instances

bsSource :: ByteString -> IO SourceSource

Construct a source from a ByteString

hSourceSource

Arguments

:: (Int64, Int64)

the first and last byte to include

-> Handle

the handle to read from

-> IO Source 

Construct a source from a Handle

nullSource :: SourceSource

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)

connSourceSource

Arguments

:: 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.

sourceDrain :: Source -> IO ()Source

Read a source until it returns SourceEOF

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

readIGSource

Arguments

:: 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

sourceIGSource

Arguments

:: 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

sslToBaseConnection :: SSL -> BaseConnectionSource

Convert an SSL connection to a BaseConnection for Network.Connection