happstack-server-7.9.3: Web related tools and services.

Safe Haskell | None
Language | Haskell2010

Happstack.Server.Internal.Multipart

Synopsis

- spanS :: (ByteString -> Bool) -> ByteString -> (ByteString, ByteString)
- takeWhileS :: (ByteString -> Bool) -> ByteString -> ByteString
- crlf :: ByteString
- crlfcrlf :: ByteString
- blankLine :: ByteString
- dropWhileS :: (ByteString -> Bool) -> ByteString -> ByteString
- data BodyPart = BodyPart ByteString ByteString
- data Work
  - = BodyWork ContentType [(String, String)] ByteString
  - | HeaderWork ByteString
- type InputWorker = Work -> IO InputIter
- data InputIter
  - = Failed (Maybe (String, Input)) String
  - | BodyResult (String, Input) InputWorker
  - | HeaderResult [Header] InputWorker
- type FileSaver = FilePath -> Int64 -> FilePath -> ByteString -> IO (Bool, Int64, FilePath)
- defaultFileSaver :: FilePath -> Int64 -> FilePath -> ByteString -> IO (Bool, Int64, FilePath)
- defaultInputIter :: FileSaver -> FilePath -> Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Work -> IO InputIter
- hPutLimit :: Int64 -> Handle -> ByteString -> IO (Bool, Int64)
- hPutLimit' :: Int64 -> Handle -> Int64 -> ByteString -> IO (Bool, Int64)
- bodyPartToInput :: InputWorker -> BodyPart -> IO InputIter
- bodyPartsToInputs :: InputWorker -> [BodyPart] -> IO ([(String, Input)], Maybe String)
- multipartBody :: InputWorker -> ByteString -> ByteString -> IO ([(String, Input)], Maybe String)
- simpleInput :: String -> Input
- defaultInputType :: ContentType
- parseMultipartBody :: ByteString -> ByteString -> ([BodyPart], Maybe String)
- dropPreamble :: ByteString -> ByteString -> (ByteString, Maybe String)
- dropLine :: ByteString -> ByteString
- isBoundary :: ByteString -> ByteString -> Bool
- startsWithDashes :: ByteString -> Bool
- splitParts :: ByteString -> ByteString -> ([BodyPart], Maybe String)
- splitPart :: ByteString -> ByteString -> (BodyPart, ByteString)
- splitBlank :: ByteString -> (ByteString, ByteString)
- splitBoundary :: ByteString -> ByteString -> (ByteString, ByteString)
- splitAtEmptyLine :: ByteString -> Maybe (ByteString, ByteString)
- splitAtCRLF :: ByteString -> Maybe (ByteString, ByteString)

# Documentation

spanS :: (ByteString -> Bool) -> ByteString -> (ByteString, ByteString) Source #

similar to the normal `span` function, except the predicate gets the whole rest of the lazy bytestring, not just one character.

TODO: this function has not been profiled.

takeWhileS :: (ByteString -> Bool) -> ByteString -> ByteString Source #

crlf :: ByteString Source #

crlfcrlf :: ByteString Source #

blankLine :: ByteString Source #

dropWhileS :: (ByteString -> Bool) -> ByteString -> ByteString Source #

data BodyPart Source #

Constructors

BodyPart ByteString ByteString | headers body

#### Instances

Instances details

Read BodyPart Source # |
Instance details Defined in Happstack.Server.Internal.Multipart Methods readsPrec :: Int -> ReadS BodyPart Source # readList :: ReadS [BodyPart] Source # readPrec :: ReadPrec BodyPart Source # readListPrec :: ReadPrec [BodyPart] Source #
Show BodyPart Source # |
Instance details Defined in Happstack.Server.Internal.Multipart Methods showsPrec :: Int -> BodyPart -> ShowS Source # show :: BodyPart -> String Source # showList :: [BodyPart] -> ShowS Source #
Eq BodyPart Source # |
Instance details Defined in Happstack.Server.Internal.Multipart Methods (==) :: BodyPart -> BodyPart -> Bool Source # (/=) :: BodyPart -> BodyPart -> Bool Source #
Ord BodyPart Source # |

Instance details

Defined in Happstack.Server.Internal.Multipart

Methods

compare :: BodyPart -> BodyPart -> Ordering Source #

(<) :: BodyPart -> BodyPart -> Bool Source #

(<=) :: BodyPart -> BodyPart -> Bool Source #

(>) :: BodyPart -> BodyPart -> Bool Source #

(>=) :: BodyPart -> BodyPart -> Bool Source #

max :: BodyPart -> BodyPart -> BodyPart Source #

min :: BodyPart -> BodyPart -> BodyPart Source #

data Work Source #

Constructors

BodyWork ContentType [(String, String)] ByteString |
HeaderWork ByteString |

type InputWorker = Work -> IO InputIter Source #

data InputIter Source #

Constructors

Failed (Maybe (String, Input)) String |
BodyResult (String, Input) InputWorker |
HeaderResult [Header] InputWorker |

type FileSaver Source #

Arguments

= FilePath | tempdir
-> Int64 | quota
-> FilePath | filename of field
-> ByteString | content to save
-> IO (Bool, Int64, FilePath) | truncated?, saved bytes, saved filename

defaultFileSaver :: FilePath -> Int64 -> FilePath -> ByteString -> IO (Bool, Int64, FilePath) Source #

defaultInputIter :: FileSaver -> FilePath -> Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> Work -> IO InputIter Source #

hPutLimit :: Int64 -> Handle -> ByteString -> IO (Bool, Int64) Source #

hPutLimit' :: Int64 -> Handle -> Int64 -> ByteString -> IO (Bool, Int64) Source #

bodyPartToInput :: InputWorker -> BodyPart -> IO InputIter Source #

bodyPartsToInputs :: InputWorker -> [BodyPart] -> IO ([(String, Input)], Maybe String) Source #

multipartBody :: InputWorker -> ByteString -> ByteString -> IO ([(String, Input)], Maybe String) Source #

simpleInput :: String -> Input Source #

Packs a string into an Input of type "text/plain"

defaultInputType :: ContentType Source #

The default content-type for variables.

parseMultipartBody :: ByteString -> ByteString -> ([BodyPart], Maybe String) Source #

dropPreamble :: ByteString -> ByteString -> (ByteString, Maybe String) Source #

dropLine :: ByteString -> ByteString Source #

isBoundary Source #

Arguments

:: ByteString | The boundary, without the initial dashes
-> ByteString |
-> Bool |

Check whether a string starts with two dashes followed by the given boundary string.

startsWithDashes :: ByteString -> Bool Source #

Checks whether a string starts with two dashes.

splitParts :: ByteString -> ByteString -> ([BodyPart], Maybe String) Source #

splitPart :: ByteString -> ByteString -> (BodyPart, ByteString) Source #

splitBlank :: ByteString -> (ByteString, ByteString) Source #

splitBoundary :: ByteString -> ByteString -> (ByteString, ByteString) Source #

splitAtEmptyLine :: ByteString -> Maybe (ByteString, ByteString) Source #

splitAtCRLF Source #

Arguments

:: ByteString | String to split.
-> Maybe (ByteString, ByteString) | Returns `Nothing` if there is no CRLF.

Split a string at the first CRLF. The CRLF is not included in any of the returned strings.